ruby-changes:22417
From: naruse <ko1@a...>
Date: Wed, 8 Feb 2012 09:44:16 +0900 (JST)
Subject: [ruby-changes:22417] naruse:r34466 (ruby_1_9_3): merge revision(s) 34028,34030:
naruse 2012-02-08 09:44:05 +0900 (Wed, 08 Feb 2012) New Revision: 34466 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34466 Log: merge revision(s) 34028,34030: * error.c (name_err_mesg_to_str): clear rb_thread_t::errinfo when ignore exception under rb_protect(). * test/ruby/test_exception.rb (test_exception_in_name_error_to_str): add a corresponding test. ignore exception under rb_protect(). [ruby-core:41612] [Bug #5755] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/error.c branches/ruby_1_9_3/test/ruby/test_exception.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 34465) +++ ruby_1_9_3/ChangeLog (revision 34466) @@ -1,3 +1,11 @@ +Wed Feb 8 09:43:48 2012 CHIKANAGA Tomoyuki <nagachika00@g...> + + * error.c (name_err_mesg_to_str): clear rb_thread_t::errinfo when + ignore exception under rb_protect(). [ruby-core:41612] [Bug #5755] + + * test/ruby/test_exception.rb (test_exception_in_name_error_to_str): + add a corresponding test. + Wed Feb 8 09:36:42 2012 Nobuyoshi Nakada <nobu@r...> * encoding.c (require_enc): reject only loading from untrusted Index: ruby_1_9_3/error.c =================================================================== --- ruby_1_9_3/error.c (revision 34465) +++ ruby_1_9_3/error.c (revision 34466) @@ -955,6 +955,7 @@ else { const char *desc = 0; VALUE d = 0, args[NAME_ERR_MESG_COUNT]; + int state = 0; obj = ptr[1]; switch (TYPE(obj)) { @@ -968,7 +969,9 @@ desc = "false"; break; default: - d = rb_protect(rb_inspect, obj, 0); + d = rb_protect(rb_inspect, obj, &state); + if (state) + rb_set_errinfo(Qnil); if (NIL_P(d) || RSTRING_LEN(d) > 65) { d = rb_any_to_s(obj); } Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 34465) +++ ruby_1_9_3/version.h (revision 34466) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 51 +#define RUBY_PATCHLEVEL 52 #define RUBY_RELEASE_DATE "2012-02-08" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/test/ruby/test_exception.rb =================================================================== --- ruby_1_9_3/test/ruby/test_exception.rb (revision 34465) +++ ruby_1_9_3/test/ruby/test_exception.rb (revision 34466) @@ -1,4 +1,5 @@ require 'test/unit' +require 'tempfile' require_relative 'envutil' class TestException < Test::Unit::TestCase @@ -316,4 +317,20 @@ def test_errno assert_equal(Encoding.find("locale"), Errno::EINVAL.new.message.encoding) end + + def test_exception_in_name_error_to_str + bug5575 = '[ruby-core:41612]' + t = Tempfile.new(["test_exception_in_name_error_to_str", ".rb"]) + t.puts <<-EOC + begin + BasicObject.new.inspect + rescue + $!.inspect + end + EOC + t.close + assert_nothing_raised(NameError, bug5575) do + load(t.path) + end + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/