summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-07-23 00:44:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-07-23 12:01:15 +0900
commit377995035a8ed42e4c0d5c84bb3c88c2d53dcf0a (patch)
treeb9c7114469d386bb9ec76b7bf3b4af92cce89760
parentfc4dd45d0142221880d1b2c9b54dee0597be2b78 (diff)
Suppress exception message in finalizer [Feature #17798]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4670
-rw-r--r--gc.c2
-rw-r--r--test/ruby/test_gc.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index 61ff6abece..da0f5ff1b2 100644
--- a/gc.c
+++ b/gc.c
@@ -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);
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index c3fc1047b6..4df9775ecc 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -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