ruby-changes:57486
From: Nobuyoshi <ko1@a...>
Date: Mon, 2 Sep 2019 17:21:35 +0900 (JST)
Subject: [ruby-changes:57486] 8b2e1ca10e (master): Do not clear backtrace in Exception#exception
https://git.ruby-lang.org/ruby.git/commit/?id=8b2e1ca10e From 8b2e1ca10ecf92ad402decd6b1eab586eded0ddb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 2 Sep 2019 16:47:12 +0900 Subject: Do not clear backtrace in Exception#exception [Bug #15558] diff --git a/error.c b/error.c index 290ab7a..2089c37 100644 --- a/error.c +++ b/error.c @@ -970,11 +970,11 @@ exc_exception(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/error.c#L970 { VALUE exc; + argc = rb_check_arity(argc, 0, 1); if (argc == 0) return self; if (argc == 1 && self == argv[0]) return self; exc = rb_obj_clone(self); - exc_initialize(argc, argv, exc); - + rb_ivar_set(exc, id_mesg, argv[0]); return exc; } diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 55f0d27..9de1b2d 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -518,6 +518,18 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L518 end; end + def test_backtrace_by_exception + begin + line = __LINE__; raise "foo" + rescue => e + end + e2 = e.exception("bar") + assert_not_equal(e.message, e2.message) + assert_equal(e.backtrace, e2.backtrace) + loc = e2.backtrace_locations[0] + assert_equal([__FILE__, line], [loc.path, loc.lineno]) + end + Bug4438 = '[ruby-core:35364]' def test_rescue_single_argument -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/