Project

General

Profile

Actions

Bug #18421

closed

`IO#readpartial` and `IO#read_nonblock` return non-empty string on empty file

Added by nobu (Nobuyoshi Nakada) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:106767]

Description

With an empty file empty_file, this seems indisputably correct.

File.open("empty_file") {|f| f.read(0, "abc")} #=> ""

OTOH, obviously these seem bugs.

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0