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"