From: "ioquatix (Samuel Williams) via ruby-core" Date: 2022-12-24T12:13:48+00:00 Subject: [ruby-core:111416] [Ruby master Bug#19252] IO::Buffer.pread last argument is always ignored? Issue #19252 has been updated by ioquatix (Samuel Williams). Status changed from Open to Closed Merged. ---------------------------------------- Bug #19252: IO::Buffer.pread last argument is always ignored? https://bugs.ruby-lang.org/issues/19252#change-100788 * Author: zverok (Victor Shepelev) * Status: Closed * 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/