Suppress exception message in finalizer [Feature #17798]

This commit is contained in:
Nobuyoshi Nakada 2021-07-23 00:44:19 +09:00
parent fc4dd45d01
commit 377995035a
Notes: git 2021-07-23 12:01:42 +09:00
2 changed files with 3 additions and 3 deletions

2
gc.c
View File

@ -3990,7 +3990,7 @@ run_single_final(VALUE cmd, VALUE objid)
static void
warn_exception_in_finalizer(rb_execution_context_t *ec, VALUE final)
{
if (final != Qundef) {
if (final != Qundef && !NIL_P(ruby_verbose)) {
VALUE errinfo = ec->errinfo;
rb_warn("Exception in finalizer %+"PRIsVALUE, final);
rb_ec_error_print(ec, errinfo);

View File

@ -459,7 +459,7 @@ class TestGc < Test::Unit::TestCase
obj = nil
}
}
GC.start
EnvUtil.suppress_warning {GC.start}
skip "finalizers did not get run" if result.empty?
assert_equal([:c1, :c2], result)
end
@ -482,7 +482,7 @@ class TestGc < Test::Unit::TestCase
obj = nil
}
}
GC.start
EnvUtil.suppress_warning {GC.start}
skip "finalizers did not get run" if @result.empty?
assert_equal([:c1, :c2], @result)
end