From: Hal Brodigan Date: 2011-08-20T10:30:11+09:00 Subject: [ruby-core:39027] [Ruby 1.9 - Bug #5207] StringIO#read(length,nil) does not behave in the same way as IO#read Issue #5207 has been updated by Hal Brodigan. Oops, that should be: file = File.new('test') file.read(2,nil) # => "12" require 'stringio' stringio = StringIO.new("hello") stringio.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 `
' ---------------------------------------- Bug #5207: StringIO#read(length,nil) does not behave in the same way as IO#read http://redmine.ruby-lang.org/issues/5207 Author: Hal Brodigan Status: Open Priority: Normal Assignee: Category: lib Target version: 1.9.3 ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] 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 `
' Effects both 1.9.2-p290 and 1.9.3-preview1. -- http://redmine.ruby-lang.org