* 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
This commit is contained in:
nobu 2013-11-09 15:36:46 +00:00
Родитель 7a330ba230
Коммит 3fdff0501a
3 изменённых файлов: 27 добавлений и 1 удалений

Просмотреть файл

@ -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

2
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));
}

Просмотреть файл

@ -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