ruby-changes:54266
From: mame <ko1@a...>
Date: Fri, 21 Dec 2018 20:44:27 +0900 (JST)
Subject: [ruby-changes:54266] mame:r66475 (trunk): eval_error.c (show_cause): check if cause is an Exception or not
mame 2018-12-21 20:44:21 +0900 (Fri, 21 Dec 2018) New Revision: 66475 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66475 Log: eval_error.c (show_cause): check if cause is an Exception or not Fixes [Bug #15447] Modified files: trunk/eval_error.c trunk/test/ruby/test_exception.rb Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 66474) +++ test/ruby/test_exception.rb (revision 66475) @@ -1341,6 +1341,15 @@ $stderr = $stdout; raise "\x82\xa0"') do https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L1341 assert_in_out_err([], code, [], /Bug14566/, success: false, timeout: 2) end + def test_non_exception_cause + puts "foo" + code = "#{<<~"begin;"}\n#{<<~'end;'}" + begin; + raise "foo", cause: 1 + end; + assert_in_out_err([], code, [], /foo/, success: false, timeout: 2) + end + def test_super_in_method_missing assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; Index: eval_error.c =================================================================== --- eval_error.c (revision 66474) +++ eval_error.c (revision 66475) @@ -226,7 +226,7 @@ static void https://github.com/ruby/ruby/blob/trunk/eval_error.c#L226 show_cause(VALUE errinfo, VALUE str, VALUE highlight, VALUE reverse) { VALUE cause = rb_attr_get(errinfo, id_cause); - if (!NIL_P(cause)) { + if (!NIL_P(cause) && rb_obj_is_kind_of(cause, rb_eException)) { volatile VALUE eclass = CLASS_OF(cause); VALUE errat = rb_get_backtrace(cause); VALUE emesg = rb_get_message(cause); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/