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) 5 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
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) 5 months ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) 5 months 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) 5 months 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) 2 months 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