summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-09 15:36:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-09 15:36:46 +0000
commit3fdff0501aab8400c0f8743b043c9e0533c5767e (patch)
tree0af23db91ca1a4c2d3780cd59fe4d746e7367b23
parent7a330ba230833b2a3215012808b6fb2ce57722cf (diff)
gc.c: private call
* gc.c (should_be_callable): allow private call since rb_eval_cmd calls even private methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--gc.c2
-rw-r--r--test/ruby/test_objectspace.rb21
3 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index cc11e64..3dcdbbe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Nov 10 00:36:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@zzak.io>
* lib/racc/rdoc/grammar.en.rdoc: [DOC] fix typo by Tsuyoshi Sawada
diff --git a/gc.c b/gc.c
index 178d52e..dda3292 100644
--- a/gc.c
+++ b/gc.c
@@ -1866,7 +1866,7 @@ rb_undefine_final(VALUE obj)
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));
}
diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb
index 3127b61..c96f973 100644
--- a/test/ruby/test_objectspace.rb
+++ b/test/ruby/test_objectspace.rb
@@ -64,6 +64,27 @@ End
!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