
Issue #19252 has been updated by ioquatix (Samuel Williams). https://github.com/ruby/ruby/pull/7012 ---------------------------------------- Bug #19252: IO::Buffer.pread last argument is always ignored? https://bugs.ruby-lang.org/issues/19252#change-100772 * Author: zverok (Victor Shepelev) * Status: Open * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- I am trying to document new `IO::Buffer#pread` and `#pwrite` methods. According to what I can guess from code and tests, this code: ```ruby IO::Buffer.for('teststring') do |buffer| buffer.pread(File.open('/dev/urandom', 'rb'), 0, 2, 3) p buffer.get_string end ``` ...is expected to read **2** chars from `/dev/urandom`, starting from **0**th char, and write it to buffer starting from its **3**rd byte. Actual output: ``` "F\x94ststring" ``` E.g. two first chars of the buffer are replaced. Am I missing something, or is it a legitimate bug?.. UPD: Seems the same for `pwrite`: ```ruby IO::Buffer.for('1234567').pwrite(File.open('tmp/buf.txt', 'wb'), 0, 2, 3) # expected to write "45" to file `cat tmp/buf.txt` # => "12" ``` -- https://bugs.ruby-lang.org/