[前][次][番号順一覧][スレッド一覧]

ruby-changes:33172

From: nagachika <ko1@a...>
Date: Mon, 3 Mar 2014 01:30:15 +0900 (JST)
Subject: [ruby-changes:33172] nagachika:r45251 (ruby_2_0_0): merge revision(s) r45178, r45179, r45180, r45183: [Backport #9568]

nagachika	2014-03-03 01:30:04 +0900 (Mon, 03 Mar 2014)

  New Revision: 45251

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45251

  Log:
    merge revision(s) r45178,r45179,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]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/eval.c
    branches/ruby_2_0_0/test/ruby/envutil.rb
    branches/ruby_2_0_0/test/ruby/test_exception.rb
    branches/ruby_2_0_0/test/ruby/test_module.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 45250)
+++ ruby_2_0_0/ChangeLog	(revision 45251)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Mar  3 01:25:28 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (setup_exception): preserve errinfo across calling #to_s
+	  method on the exception.  [ruby-core:61091] [Bug #9568]
+
 Mon Mar  3 01:00:00 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* numeric.c (ruby_num_interval_step_size): check signs and get rid
Index: ruby_2_0_0/eval.c
===================================================================
--- ruby_2_0_0/eval.c	(revision 45250)
+++ ruby_2_0_0/eval.c	(revision 45251)
@@ -467,9 +467,12 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval.c#L467
 	!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 - %s\n",
 			    rb_obj_classname(th->errinfo),
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 45250)
+++ ruby_2_0_0/version.h	(revision 45251)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-03-03"
-#define RUBY_PATCHLEVEL 454
+#define RUBY_PATCHLEVEL 455
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_0_0/test/ruby/test_module.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_module.rb	(revision 45250)
+++ ruby_2_0_0/test/ruby/test_module.rb	(revision 45251)
@@ -1500,17 +1500,11 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_module.rb#L1500
   end
 
   def labeled_module(name, &block)
-    Module.new do
-      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
-      class_eval(&block) if block
-    end
+    EnvUtil.labeled_module(name, &block)
   end
 
   def labeled_class(name, superclass = Object, &block)
-    Class.new(superclass) do
-      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
-      class_eval(&block) if block
-    end
+    EnvUtil.labeled_class(name, superclass, &block)
   end
 
   def test_prepend_instance_methods_false
Index: ruby_2_0_0/test/ruby/envutil.rb
===================================================================
--- ruby_2_0_0/test/ruby/envutil.rb	(revision 45250)
+++ ruby_2_0_0/test/ruby/envutil.rb	(revision 45251)
@@ -150,6 +150,22 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/envutil.rb#L150
     $VERBOSE = verbose
   end
   module_function :with_default_internal
+
+  def labeled_module(name, &block)
+    Module.new do
+      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
+      class_eval(&block) if block
+    end
+  end
+  module_function :labeled_module
+
+  def labeled_class(name, superclass = Object, &block)
+    Class.new(superclass) do
+      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
+      class_eval(&block) if block
+    end
+  end
+  module_function :labeled_class
 end
 
 module Test
Index: ruby_2_0_0/test/ruby/test_exception.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_exception.rb	(revision 45250)
+++ ruby_2_0_0/test/ruby/test_exception.rb	(revision 45251)
@@ -80,6 +80,28 @@ class TestException < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_exception.rb#L80
     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

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45178-45180,45183


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]