Project

General

Profile

Actions

Backport #5207

closed

StringIO#read(length,nil) does not behave in the same way as IO#read

Added by postmodern (Hal Brodigan) over 12 years ago. Updated almost 8 years ago.

Status:
Rejected
[ruby-core:39026]

Description

I noticed an incompatibility between IO#read(length,buffer) and StringIO#read, when buffer is nil.

file = File.read('test')
file.read(2,nil)
# => "12"

string = StringIO.new("hello")
string.read(2,nil)
TypeError: can't convert nil into String
from (irb):3:in `read'
from (irb):3
from /home/hal/.rvm/rubies/ruby-1.9.3-preview1/bin/irb:16:in `<main>'

Effects both 1.9.2-p290 and 1.9.3-preview1.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0