* ext/stringio/stringio.c (strio_ungetc): raise IOError instead of RuntimeError
if the string is frozen. [Bug #7231] [ruby-core:48530] * ext/stringio/stringio.c (strio_ungetbyte): ditto. * test/stringio/test_stringio.rb: a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
90833dd452
commit
cd453f16b4
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Thu Dec 27 20:11:29 2012 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_ungetc): raise IOError instead of RuntimeError
|
||||||
|
if the string is frozen.
|
||||||
|
[Bug #7231] [ruby-core:48530]
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_ungetbyte): ditto.
|
||||||
|
|
||||||
|
* test/stringio/test_stringio.rb: a test for above.
|
||||||
|
|
||||||
Wed Dec 26 23:55:18 2012 Keiju Ishitsuka <keiju@ishitsuka.com>
|
Wed Dec 26 23:55:18 2012 Keiju Ishitsuka <keiju@ishitsuka.com>
|
||||||
|
|
||||||
* lib/irb/context.rb: fix IRB::Inspector#keys_with_inspector [Bug #7598]
|
* lib/irb/context.rb: fix IRB::Inspector#keys_with_inspector [Bug #7598]
|
||||||
|
@ -737,6 +737,7 @@ strio_ungetc(VALUE self, VALUE c)
|
|||||||
rb_encoding *enc, *enc2;
|
rb_encoding *enc, *enc2;
|
||||||
|
|
||||||
if (NIL_P(c)) return Qnil;
|
if (NIL_P(c)) return Qnil;
|
||||||
|
check_modifiable(ptr);
|
||||||
if (FIXNUM_P(c)) {
|
if (FIXNUM_P(c)) {
|
||||||
int cc = FIX2INT(c);
|
int cc = FIX2INT(c);
|
||||||
char buf[16];
|
char buf[16];
|
||||||
@ -801,6 +802,7 @@ strio_ungetbyte(VALUE self, VALUE c)
|
|||||||
cl = RSTRING_LEN(c);
|
cl = RSTRING_LEN(c);
|
||||||
if (cl == 0) return Qnil;
|
if (cl == 0) return Qnil;
|
||||||
}
|
}
|
||||||
|
check_modifiable(ptr);
|
||||||
rb_str_modify(str);
|
rb_str_modify(str);
|
||||||
if (cl > pos) {
|
if (cl > pos) {
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -504,6 +504,14 @@ class TestStringIO < Test::Unit::TestCase
|
|||||||
assert_raise(RuntimeError, bug) {s.reopen("")}
|
assert_raise(RuntimeError, bug) {s.reopen("")}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_frozen_string
|
||||||
|
s = StringIO.new("".freeze)
|
||||||
|
bug = '[ruby-core:48530]'
|
||||||
|
assert_raise(IOError, bug) {s.write("foo")}
|
||||||
|
assert_raise(IOError, bug) {s.ungetc("a")}
|
||||||
|
assert_raise(IOError, bug) {s.ungetbyte("a")}
|
||||||
|
end
|
||||||
|
|
||||||
def test_readlines_limit_0
|
def test_readlines_limit_0
|
||||||
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.readlines(0) }
|
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.readlines(0) }
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user