ruby-changes:37881
From: nobu <ko1@a...>
Date: Fri, 13 Mar 2015 15:04:49 +0900 (JST)
Subject: [ruby-changes:37881] nobu:r49962 (trunk): stringio.c: don't raise after close
nobu 2015-03-13 15:04:39 +0900 (Fri, 13 Mar 2015) New Revision: 49962 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49962 Log: stringio.c: don't raise after close * ext/stringio/stringio.c (strio_close): don't raise on dobule close for consistent to IO#close. Modified files: trunk/ChangeLog trunk/ext/stringio/stringio.c trunk/test/stringio/test_stringio.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49961) +++ ChangeLog (revision 49962) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Mar 13 15:04:36 2015 Nobuyoshi Nakada <nobu@r...> + + * ext/stringio/stringio.c (strio_close): don't raise on dobule + close for consistent to IO#close. + Fri Mar 13 15:03:20 2015 Nobuyoshi Nakada <nobu@r...> * io.c (rb_io_close_read, rb_io_close_write): don't raise after Index: ext/stringio/stringio.c =================================================================== --- ext/stringio/stringio.c (revision 49961) +++ ext/stringio/stringio.c (revision 49962) @@ -360,8 +360,8 @@ strio_close(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L360 static VALUE strio_close_read(VALUE self) { - StringIO(self); - if (!READABLE(self)) { + struct StringIO *ptr = StringIO(self); + if (!(ptr->flags & FMODE_READABLE)) { rb_raise(rb_eIOError, "closing non-duplex IO for reading"); } RBASIC(self)->flags &= ~STRIO_READABLE; @@ -378,8 +378,8 @@ strio_close_read(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L378 static VALUE strio_close_write(VALUE self) { - StringIO(self); - if (!WRITABLE(self)) { + struct StringIO *ptr = StringIO(self); + if (!(ptr->flags & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "closing non-duplex IO for writing"); } RBASIC(self)->flags &= ~STRIO_WRITABLE; Index: test/stringio/test_stringio.rb =================================================================== --- test/stringio/test_stringio.rb (revision 49961) +++ test/stringio/test_stringio.rb (revision 49962) @@ -207,7 +207,7 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/stringio/test_stringio.rb#L207 f = StringIO.new("") f.close_read assert_raise(IOError) { f.read } - assert_raise(IOError) { f.close_read } + assert_nothing_raised(IOError) {f.close_read} f.close f = StringIO.new("", "w") @@ -221,7 +221,7 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/stringio/test_stringio.rb#L221 f = StringIO.new("") f.close_write assert_raise(IOError) { f.write("foo") } - assert_raise(IOError) { f.close_write } + assert_nothing_raised(IOError) {f.close_write} f.close f = StringIO.new("", "r") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/