diff --git a/ChangeLog b/ChangeLog index cc11e64501..3dcdbbe61e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 10 00:36:42 2013 Nobuyoshi Nakada + + * 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 * lib/racc/rdoc/grammar.en.rdoc: [DOC] fix typo by Tsuyoshi Sawada diff --git a/gc.c b/gc.c index 178d52e822..dda3292b60 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 3127b61abe..c96f973895 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