Forum: Ruby-core StringIO: RubySpec violation

204784d162fece694532d2ef5cdc5ca5?d=identicon&s=25 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?
9d2f78236e45a335301ba1195026105d?d=identicon&s=25 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
204784d162fece694532d2ef5cdc5ca5?d=identicon&s=25 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.
9d2f78236e45a335301ba1195026105d?d=identicon&s=25 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.
9d2f78236e45a335301ba1195026105d?d=identicon&s=25 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.
This topic is locked and can not be replied to.