diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-07-23 00:44:19 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-07-23 12:01:15 +0900 |
commit | 377995035a8ed42e4c0d5c84bb3c88c2d53dcf0a (patch) | |
tree | b9c7114469d386bb9ec76b7bf3b4af92cce89760 | |
parent | fc4dd45d0142221880d1b2c9b54dee0597be2b78 (diff) |
Suppress exception message in finalizer [Feature #17798]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4670
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | test/ruby/test_gc.rb | 4 |
2 files changed, 3 insertions, 3 deletions
@@ -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 |