% svn diff --diff-cmd diff -x '-u -p'
Index: io.c
===================================================================
--- io.c (revision 49185)
+++ io.c (working copy)
@@ -4415,11 +4415,18 @@ rb_io_close(VALUE io)
*
* If ios is opened by IO.popen
,
* close
sets $?
.
+ *
+ * Calling this method on closed IO object is just ignored since Ruby 2.3.
*/
static VALUE
rb_io_close_m(VALUE io)
{
+ rb_io_t *fptr = RFILE(io)->fptr;
+ rb_io_check_initialized(fptr);
+ if (fptr->fd < 0) {
+ return Qnil;
+ }
rb_io_check_closed(RFILE(io)->fptr);
rb_io_close(io);
return Qnil;
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb (revision 49185)
+++ test/ruby/test_io.rb (working copy)
@@ -3159,4 +3159,17 @@ End
end
end
end
+
+ def test_close_twice
+ open(__FILE__) {|f|
+ assert_equal(nil, f.close)
+ assert_equal(nil, f.close)
+ }
+ end
+
+ def test_close_uninitialized
+ io = IO.allocate
+ assert_raise(IOError) { io.close }
+ end
+
end
Index: test/socket/test_basicsocket.rb
===================================================================
--- test/socket/test_basicsocket.rb (revision 49185)
+++ test/socket/test_basicsocket.rb (working copy)
@@ -9,7 +9,7 @@ class TestSocket_BasicSocket < Test::Uni
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
yield sock
ensure
- assert_raise(IOError) {sock.close}
+ assert(sock.closed?)
end
def test_getsockopt
Index: test/zlib/test_zlib.rb
===================================================================
--- test/zlib/test_zlib.rb (revision 49185)
+++ test/zlib/test_zlib.rb (working copy)
@@ -929,7 +929,7 @@ if defined? Zlib
f = open(t.path)
f.binmode
assert_equal("foo", Zlib::GzipReader.wrap(f) {|gz| gz.read })
- assert_raise(IOError) { f.close }
+ assert(f.closed?)
}
end