Forum: Ruby-core StringIO: RubySpec violation

Posted by Hongli Lai (Guest)
on 2009-04-20 21:57
(Received via mailing list)
I ran RubySpec against the 1.8.6-p368 release. It seems that
StringIO#ungetc changed.

p368:
irb(main):001:0> io = StringIO.new("1234")
=> #<StringIO:0x208f14>
irb(main):002:0> io.ungetc(65)
=> nil
irb(main):003:0> io.string
=> "A1234"


p287:
irb(main):001:0> io = StringIO.new("1234")
=> #<StringIO:0x208fa0>
irb(main):002:0> io.ungetc(65)
=> nil
irb(main):003:0> io.string
=> "1234"

1.9:
=> #<StringIO:0x419948>
irb(main):002:0> io.ungetc(65)
=> nil
irb(main):003:0> io.string
=> "A1234"
irb(main):004:0>

Is this intentional?
Posted by Urabe Shyouhei (Guest)
on 2009-04-20 22:16
(Received via mailing list)
Hongli Lai wrote:
> Is this intentional?

Yes. http://redmine.ruby-lang.org/issues/show/701
Posted by Hongli Lai (Guest)
on 2009-04-20 22:29
(Received via mailing list)
Urabe Shyouhei wrote:
> Hongli Lai wrote:
>> Is this intentional?
> 
> Yes. http://redmine.ruby-lang.org/issues/show/701
> 
> 

But is the backport to the 1.8.6 series intentional as well? I thought
behavior changes like this are reserved for the 1.8.7 series.
Posted by Urabe Shyouhei (Guest)
on 2009-04-20 22:40
(Received via mailing list)
Hongli Lai wrote:
> Urabe Shyouhei wrote:
>> Hongli Lai wrote:
>>> Is this intentional?
>>
>> Yes. http://redmine.ruby-lang.org/issues/show/701
>>
>>
> 
> But is the backport to the 1.8.6 series intentional as well? I thought
> behavior changes like this are reserved for the 1.8.7 series.

The answer is yes; it seemed to me a bug anyway for stringio to silently 
ignore
 a passed argument.  I thought it should accept that (as it does now), 
or at
least raise an exception such as IndexError.
Posted by Urabe Shyouhei (Guest)
on 2009-04-20 22:49
(Received via mailing list)
Urabe Shyouhei wrote:
> The answer is yes; it seemed to me a bug anyway for stringio to silently ignore
>  a passed argument.  I thought it should accept that (as it does now), or at
> least raise an exception such as IndexError.

Hmm, maybe IOError is the best exception to raise because IO#ungetc 
raises it
in case of failures.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.