ruby / stringio

Pseudo `IO` class from/to `String`.
BSD 2-Clause "Simplified" License
33 stars 26 forks source link

pread(0,0) raises EOFError #66

Closed jdelStrother closed 11 months ago

jdelStrother commented 11 months ago

@casperisfine / @byroot thanks for the pread implementation!

However, there's a slight difference in how it treats the edge case of reading zero bytes from an empty file

File.open("empty_file").pread(0,0) # => ""
StringIO.new(File.read("empty_file")).pread(0,0) # => raises `end of file reached (EOFError)`

In our case, this is almost certainly a bug in the application logic where it ought to bail out early rather than trying to read zero bytes from the io, but thought it was worth highlighting the discrepancy.

byroot commented 11 months ago

Thanks. I'm busy for the next couple days but I'll make sure to have a look next week.