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 #1

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset git|fdf39963490cf2cf95b30d91bb9b35964c2c2350.


Empty and return the buffer if zero size is given [Bug #18421]

In IO#readpartial and IO#read_nonblock, as well as IO#read.

Updated by usa (Usaku NAKAMURA) about 2 years ago

  • 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.

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0