From: "usa (Usaku NAKAMURA)" Date: 2021-12-31T10:33:35+00:00 Subject: [ruby-core:106932] [Ruby master Bug#18421] `IO#readpartial` and `IO#read_nonblock` return non-empty string on empty file Issue #18421 has been updated by usa (Usaku NAKAMURA). Backport changed from 2.6: REQUIRED, 2.7: REQUIRED, 3.0: REQUIRED to 2.6: REQUIRED, 2.7: DONE, 3.0: REQUIRED ruby_2_7 c4a5eaf37b9bf87f8324a7070c8dbc597b89c4fc 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-95753 * Author: nobu (Nobuyoshi Nakada) * Status: Closed * Priority: Normal * Backport: 2.6: REQUIRED, 2.7: DONE, 3.0: REQUIRED ---------------------------------------- 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: