Bug #7232

StringIO#gets(nil, nil) raises TypeError, IO/File#gets do not

Added by Brian Shirai over 1 year ago. Updated over 1 year ago.

[ruby-core:48531]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:ext
Target version:2.0.0
ruby -v:ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin10.8.0] Backport:

Description

Is this a bug?

sasha:rubinius brian$ irb
1.9.3p286 :001 > require 'stringio'
=> true
1.9.3p286 :002 > s = StringIO.new "abc"
=> #StringIO:0x000001008b3d90
1.9.3p286 :003 > s.gets nil, nil
TypeError: no implicit conversion from nil to integer
from (irb):3:in gets'
from (irb):3
from /Users/brian/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in
'

sasha:rubinius brian$ irb
1.9.3p286 :001 > f = File.open "foobar.txt"
=> #File:foobar.txt
1.9.3p286 :002 > io = IO.new f.fileno
=> #
1.9.3p286 :003 > io.gets nil, nil
=> "ありがとう\n"
1.9.3p286 :004 > f.rewind
=> 0
1.9.3p286 :005 > f.gets nil, nil
=> "ありがとう\n"

Thanks,
Brian

patch.diff Magnifier (966 Bytes) Masaki Matsushita, 12/25/2012 01:16 PM

Associated revisions

Revision 38630
Added by glass over 1 year ago

  • ext/stringio/stringio.c (strio_getline): fix not to raise TypeError
    when limit is nil.
    [Bug #7232]

  • test/stringio/test_stringio.rb: a test for above.

History

#1 Updated by Usaku NAKAMURA over 1 year ago

  • Category set to ext
  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada
  • Target version set to 2.0.0

can reproduce with current trunk.

#2 Updated by Masaki Matsushita over 1 year ago

How about the patch?

#3 Updated by Anonymous over 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38630.
Brian, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/stringio/stringio.c (strio_getline): fix not to raise TypeError
    when limit is nil.
    [Bug #7232]

  • test/stringio/test_stringio.rb: a test for above.

Also available in: Atom PDF