[前][次][番号順一覧][スレッド一覧]

ruby-changes:35286

From: usa <ko1@a...>
Date: Wed, 3 Sep 2014 13:39:59 +0900 (JST)
Subject: [ruby-changes:35286] usa:r47368 (ruby_2_0_0): merge revision(s) 46151, 46165: [Backport #9865]

usa	2014-09-03 13:39:50 +0900 (Wed, 03 Sep 2014)

  New Revision: 47368

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47368

  Log:
    merge revision(s) 46151,46165: [Backport #9865]
    
    * io.c (rb_io_fileno, rb_io_inspect): non-modification does not
      error on frozen IO.  [ruby-dev:48241] [Bug #9865]
    
    * io.c (rb_io_autoclose_p): Don't raise on frozen IO.
    
    * test/lib/minitest/unit.rb: IO#autoclose? may raise IOError.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/io.c
    branches/ruby_2_0_0/test/ruby/test_io.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 47367)
+++ ruby_2_0_0/ChangeLog	(revision 47368)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Wed Sep  3 13:23:29 2014  Tanaka Akira  <akr@f...>
+
+	* io.c (rb_io_autoclose_p): Don't raise on frozen IO.
+
+	* test/lib/minitest/unit.rb: IO#autoclose? may raise IOError.
+
+Wed Sep  3 13:23:29 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (rb_io_fileno, rb_io_inspect): non-modification does not
+	  error on frozen IO.  [ruby-dev:48241] [Bug #9865]
+
 Wed Sep  3 13:17:38 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (posix_fadvise): disable use of posix_fadvise
Index: ruby_2_0_0/io.c
===================================================================
--- ruby_2_0_0/io.c	(revision 47367)
+++ ruby_2_0_0/io.c	(revision 47368)
@@ -583,12 +583,18 @@ rb_eof_error(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L583
     rb_raise(rb_eEOFError, "end of file reached");
 }
 
-VALUE
-rb_io_taint_check(VALUE io)
+static VALUE
+taint_check(VALUE io)
 {
     if (!OBJ_UNTRUSTED(io) && rb_safe_level() >= 4)
 	rb_raise(rb_eSecurityError, "Insecure: operation on trusted IO");
-    rb_check_frozen(io);
+    return io;
+}
+
+VALUE
+rb_io_taint_check(VALUE io)
+{
+    rb_check_frozen(taint_check(io));
     return io;
 }
 
@@ -1877,10 +1883,10 @@ rb_io_fdatasync(VALUE io) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L1883
 static VALUE
 rb_io_fileno(VALUE io)
 {
-    rb_io_t *fptr;
+    rb_io_t *fptr = RFILE(io)->fptr;
     int fd;
 
-    GetOpenFile(io, fptr);
+    rb_io_check_closed(fptr);
     fd = fptr->fd;
     return INT2FIX(fd);
 }
@@ -1932,7 +1938,7 @@ rb_io_inspect(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L1938
     VALUE result;
     static const char closed[] = " (closed)";
 
-    fptr = RFILE(rb_io_taint_check(obj))->fptr;
+    fptr = RFILE(taint_check(obj))->fptr;
     if (!fptr) return rb_any_to_s(obj);
     result = rb_str_new_cstr("#<");
     rb_str_append(result, rb_class_name(CLASS_OF(obj)));
@@ -7452,9 +7458,9 @@ rb_io_s_for_fd(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L7458
 static VALUE
 rb_io_autoclose_p(VALUE io)
 {
-    rb_io_t *fptr;
+    rb_io_t *fptr = RFILE(io)->fptr;
     rb_secure(4);
-    GetOpenFile(io, fptr);
+    rb_io_check_closed(fptr);
     return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue;
 }
 
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 47367)
+++ ruby_2_0_0/version.h	(revision 47368)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-09-03"
-#define RUBY_PATCHLEVEL 546
+#define RUBY_PATCHLEVEL 547
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 9
Index: ruby_2_0_0/test/ruby/test_io.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_io.rb	(revision 47367)
+++ ruby_2_0_0/test/ruby/test_io.rb	(revision 47368)
@@ -1003,6 +1003,8 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_io.rb#L1003
       assert_raise(SecurityError) do
         safe_4 { r.inspect }
       end
+      r.freeze
+      assert_match(/^#<IO:fd \d+>$/, r.inspect)
     end
   end
 
@@ -2556,6 +2558,21 @@ End https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_io.rb#L2558
     assert_equal(2, $stderr.fileno)
   end
 
+  def test_frozen_fileno
+    bug9865 = '[ruby-dev:48241] [Bug #9865]'
+    with_pipe do |r,w|
+      fd = r.fileno
+      assert_equal(fd, r.freeze.fileno, bug9865)
+    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

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46151,46165


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]