aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--io.c4
-rw-r--r--test/lib/minitest/unit.rb12
-rw-r--r--test/ruby/test_io.rb7
4 files changed, 21 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f32f675a2..fba13c58e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue May 27 19:07:26 2014 Tanaka Akira <akr@fsij.org>
+
+ * io.c (rb_io_autoclose_p): Don't raise on frozen IO.
+
+ * test/lib/minitest/unit.rb: IO#autoclose? may raise IOError.
+
Tue May 27 19:01:49 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* test/openssl/test_pair.rb: Modify TestSSL#test_read_and_write
diff --git a/io.c b/io.c
index 61a77d7a25..9752021119 100644
--- a/io.c
+++ b/io.c
@@ -7607,8 +7607,8 @@ rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass)
static VALUE
rb_io_autoclose_p(VALUE io)
{
- rb_io_t *fptr;
- GetOpenFile(io, fptr);
+ rb_io_t *fptr = RFILE(io)->fptr;
+ rb_io_check_closed(fptr);
return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue;
}
diff --git a/test/lib/minitest/unit.rb b/test/lib/minitest/unit.rb
index 25160340db..5847da7d8c 100644
--- a/test/lib/minitest/unit.rb
+++ b/test/lib/minitest/unit.rb
@@ -1009,19 +1009,20 @@ module MiniTest
h = {}
ObjectSpace.each_object(IO) {|io|
begin
+ autoclose = io.autoclose?
fd = io.fileno
rescue IOError # closed IO object
next
end
- (h[fd] ||= []) << io
+ (h[fd] ||= []) << [io, autoclose]
}
fd_leaked.each {|fd|
str = ''
if h[fd]
str << ' :'
- h[fd].map {|io|
+ h[fd].map {|io, autoclose|
s = ' ' + io.inspect
- s << "(not-autoclose)" if !io.autoclose?
+ s << "(not-autoclose)" if !autoclose
s
}.each {|s|
str << s
@@ -1029,9 +1030,8 @@ module MiniTest
end
puts "Leaked file descriptor: #{name}: #{fd}#{str}"
}
- h.each {|fd, ios|
- next if ios.length <= 1
- list = ios.map {|io| [io, io.autoclose?] }
+ h.each {|fd, list|
+ next if list.length <= 1
if 1 < list.count {|io, autoclose| autoclose }
str = list.map {|io, autoclose| " #{io.inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join
puts "Multiple autoclose IO object for a file descriptor:#{str}"
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 0d5671a267..4cfd873a0d 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2796,6 +2796,13 @@ End
end
end
+ def test_frozen_autoclose
+ with_pipe do |r,w|
+ fd = r.fileno
+ assert_equal(true, r.freeze.autoclose?)
+ end
+ end
+
def test_sysread_locktmp
bug6099 = '[ruby-dev:45297]'
buf = " " * 100