summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/stringio/stringio.c8
-rw-r--r--test/stringio/test_stringio.rb4
3 files changed, 11 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fa841fe..ea4f583 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Mar 13 15:04:36 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* io.c (rb_io_close_read, rb_io_close_write): don't raise after
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 78988e1..ed141dd 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -360,8 +360,8 @@ strio_close(VALUE self)
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)
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;
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index 6ba1e25..966bbe1 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -207,7 +207,7 @@ class TestStringIO < Test::Unit::TestCase
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::TestCase
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")