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

ruby-changes:31542

From: nobu <ko1@a...>
Date: Sun, 10 Nov 2013 00:36:51 +0900 (JST)
Subject: [ruby-changes:31542] nobu:r43621 (trunk): gc.c: private call

nobu	2013-11-10 00:36:46 +0900 (Sun, 10 Nov 2013)

  New Revision: 43621

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

  Log:
    gc.c: private call
    
    * gc.c (should_be_callable): allow private call since rb_eval_cmd
      calls even private methods.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/test/ruby/test_objectspace.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43620)
+++ ChangeLog	(revision 43621)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov 10 00:36:42 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* gc.c (should_be_callable): allow private call since rb_eval_cmd
+	  calls even private methods.
+
 Sun Nov 10 00:33:17 2013  Zachary Scott  <e@z...>
 
 	* lib/racc/rdoc/grammar.en.rdoc: [DOC] fix typo by Tsuyoshi Sawada
Index: gc.c
===================================================================
--- gc.c	(revision 43620)
+++ gc.c	(revision 43621)
@@ -1866,7 +1866,7 @@ rb_undefine_final(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L1866
 static void
 should_be_callable(VALUE block)
 {
-    if (!rb_respond_to(block, rb_intern("call"))) {
+    if (!rb_obj_respond_to(block, rb_intern("call"), TRUE)) {
 	rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
 		 rb_obj_classname(block));
     }
Index: test/ruby/test_objectspace.rb
===================================================================
--- test/ruby/test_objectspace.rb	(revision 43620)
+++ test/ruby/test_objectspace.rb	(revision 43621)
@@ -64,6 +64,27 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_objectspace.rb#L64
       !b
     END
     assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) }
+    fin = Struct.new(:garbage).new
+    class << fin
+      alias call garbage=
+    end
+    assertion = proc do
+      fin.garbage = nil
+      assert_nothing_raised(ArgumentError) {
+        EnvUtil.under_gc_stress do
+          3.times do
+            ObjectSpace.define_finalizer([], fin)
+          end
+          GC.start
+        end
+      }
+      assert_not_nil(fin.garbage)
+    end
+    assertion.call
+    class << fin
+      private :call
+    end
+    assertion.call
   end
 
   def test_each_object

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

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