From: "nagachika (Tomoyuki Chikanaga)" Date: 2022-03-12T07:57:25+00:00 Subject: [ruby-core:107861] [Ruby master Bug#18421] `IO#readpartial` and `IO#read_nonblock` return non-empty string on empty file Issue #18421 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 2.6: REQUIRED, 2.7: DONE, 3.0: REQUIRED to 2.6: REQUIRED, 2.7: DONE, 3.0: DONE ruby_3_0 7c0537906314f0c2a317b37661ccdec8dddc6277 merged revision(s) fdf39963490cf2cf95b30d91bb9b35964c2c2350. ---------------------------------------- Bug #18421: `IO#readpartial` and `IO#read_nonblock` return non-empty string on empty file https://bugs.ruby-lang.org/issues/18421#change-96800 * Author: nobu (Nobuyoshi Nakada) * Status: Closed * Priority: Normal * Backport: 2.6: REQUIRED, 2.7: DONE, 3.0: DONE ---------------------------------------- With an empty file `empty_file`, this seems indisputably correct. ```ruby File.open("empty_file") {|f| f.read(0, "abc")} #=> "" ``` OTOH, obviously these seem bugs. ```ruby File.open("empty_file") {|f|f.readpartial(0, "abc")} #=> "abc" File.open("empty_file") {|f|f.read_nonblock(0, "abc")} #=> "abc" ``` https://github.com/ruby/ruby/pull/5323 -- https://bugs.ruby-lang.org/ Unsubscribe: