From fca433e2fdc014b742d22dcbd0d62e4ad83a1cea Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 29 May 2014 15:19:03 +0000 Subject: [PATCH] merge revision(s) r45178,r45180,r45183: [Backport #9568] eval.c: remove unneeded GC guard * eval.c (setup_exception): remove RB_GC_GUARD which is no longer needed since r41598. * eval.c (setup_exception): preserve errinfo across calling #to_s method on the exception. [ruby-core:61091] [Bug #9568] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 5 ++++- test/ruby/test_exception.rb | 22 ++++++++++++++++++++++ version.h | 6 +++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b08393df2f..6e6c054388 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri May 30 00:13:19 2014 Nobuyoshi Nakada + + * eval.c (setup_exception): preserve errinfo across calling #to_s + method on the exception. [ruby-core:61091] [Bug #9568] + Thu May 29 20:57:59 2014 Nobuyoshi Nakada * numeric.c (ruby_num_interval_step_size): check signs and get rid diff --git a/eval.c b/eval.c index 841b3671e3..d4dcaa1111 100644 --- a/eval.c +++ b/eval.c @@ -507,9 +507,12 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg) !rb_obj_is_kind_of(e, rb_eSystemExit)) { int status; + mesg = e; PUSH_TAG(); if ((status = EXEC_TAG()) == 0) { - RB_GC_GUARD(e) = rb_obj_as_string(e); + th->errinfo = Qnil; + e = rb_obj_as_string(mesg); + th->errinfo = mesg; if (file && line) { warn_printf("Exception `%s' at %s:%d - %"PRIsVALUE"\n", rb_obj_classname(th->errinfo), file, line, e); diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index dfa428912e..f358c00f97 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -78,6 +78,28 @@ class TestException < Test::Unit::TestCase assert(!bad) end + def test_errinfo_in_debug + bug9568 = EnvUtil.labeled_class("[ruby-core:61091] [Bug #9568]", RuntimeError) do + def to_s + require '\0' + rescue LoadError + self.class.to_s + end + end + + err = EnvUtil.verbose_warning do + assert_raise(bug9568) do + $DEBUG, debug = true, $DEBUG + begin + raise bug9568 + ensure + $DEBUG = debug + end + end + end + assert_include(err, bug9568.to_s) + end + def test_break_ensure bad = true while true diff --git a/version.h b/version.h index 16d5338638..f6cc9b838a 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-05-29" -#define RUBY_PATCHLEVEL 116 +#define RUBY_RELEASE_DATE "2014-05-30" +#define RUBY_PATCHLEVEL 117 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 29 +#define RUBY_RELEASE_DAY 30 #include "ruby/version.h"