ruby-changes:22252
From: nagachika <ko1@a...>
Date: Sat, 14 Jan 2012 18:36:31 +0900 (JST)
Subject: [ruby-changes:22252] nagachika:r34301 (trunk): * error.c (exc_equal): clear rb_thread_t::errinfo when ignore
nagachika 2012-01-14 18:36:18 +0900 (Sat, 14 Jan 2012) New Revision: 34301 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34301 Log: * error.c (exc_equal): clear rb_thread_t::errinfo when ignore an exception under rb_protect(). [ruby-core:41979] [Bug #5865] Modified files: trunk/ChangeLog trunk/error.c trunk/test/ruby/test_exception.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34300) +++ ChangeLog (revision 34301) @@ -1,3 +1,8 @@ +Sat Jan 14 18:24:13 2012 CHIKANAGA Tomoyuki <nagachika00@g...> + + * error.c (exc_equal): clear rb_thread_t::errinfo when ignore + an exception under rb_protect(). [ruby-core:41979] [Bug #5865] + Sat Jan 14 12:02:55 2012 Nobuyoshi Nakada <nobu@r...> * sprintf.c (rb_enc_vsprintf): relaxed the restriction. since the Index: error.c =================================================================== --- error.c (revision 34300) +++ error.c (revision 34301) @@ -746,7 +746,10 @@ CONST_ID(id_backtrace, "backtrace"); obj = rb_protect(try_convert_to_exception, obj, &status); - if (status || obj == Qundef) return Qfalse; + if (status || obj == Qundef) { + rb_set_errinfo(Qnil); + return Qfalse; + } if (rb_obj_class(exc) != rb_obj_class(obj)) return Qfalse; mesg = rb_check_funcall(obj, id_message, 0, 0); if (mesg == Qundef) return Qfalse; Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 34300) +++ test/ruby/test_exception.rb (revision 34301) @@ -379,6 +379,8 @@ assert_nothing_raised(NameError, bug5575) do load(t.path) end + ensure + t.close(true) if t end def test_equal @@ -386,4 +388,21 @@ assert_equal(RuntimeError.new("a"), RuntimeError.new("a"), bug5865) assert_not_equal(RuntimeError.new("a"), StandardError.new("a"), bug5865) end + + def test_exception_in_exception_equal + bug5865 = '[ruby-core:41979]' + t = Tempfile.new(["test_exception_in_exception_equal", ".rb"]) + t.puts <<-EOC + o = Object.new + def o.exception(arg) + end + RuntimeError.new("a") == o + EOC + t.close + assert_nothing_raised(ArgumentError, bug5865) do + load(t.path) + end + ensure + t.close(true) if t + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/