Project

General

Profile

Feature #10718 ยป io-close.patch

akr (Akira Tanaka), 01/09/2015 01:44 AM

View differences:

io.c (working copy)
*
* If <em>ios</em> is opened by <code>IO.popen</code>,
* <code>close</code> sets <code>$?</code>.
*
* 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;
test/ruby/test_io.rb (working copy)
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
test/socket/test_basicsocket.rb (working copy)
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
test/zlib/test_zlib.rb (working copy)
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
    (1-1/1)