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

ruby-changes:40168

From: shugo <ko1@a...>
Date: Sat, 24 Oct 2015 00:41:13 +0900 (JST)
Subject: [ruby-changes:40168] shugo:r52249 (trunk): * lib/forwardable (def_instance_delegator, def_single_delegator):

shugo	2015-10-24 00:41:04 +0900 (Sat, 24 Oct 2015)

  New Revision: 52249

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

  Log:
    * lib/forwardable (def_instance_delegator, def_single_delegator):
      rescue ::Exception instead of Exception in case Exception is
      defined under the target class.
      [ruby-core:71175] [Ruby trunk - Bug #11615]

  Modified files:
    trunk/ChangeLog
    trunk/lib/forwardable.rb
    trunk/test/test_forwardable.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52248)
+++ ChangeLog	(revision 52249)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Oct 24 00:38:34 2015  Shugo Maeda  <shugo@r...>
+
+	* lib/forwardable (def_instance_delegator, def_single_delegator):
+	  rescue ::Exception instead of Exception in case Exception is
+	  defined under the target class.
+	  [ruby-core:71175] [Ruby trunk - Bug #11615]
+
 Fri Oct 23 21:10:37 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* error.c (name_err_mesg_to_str): separate class names from the
Index: lib/forwardable.rb
===================================================================
--- lib/forwardable.rb	(revision 52248)
+++ lib/forwardable.rb	(revision 52249)
@@ -181,7 +181,7 @@ module Forwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L181
       def #{ali}(*args, &block)
         begin
           #{accessor}.__send__(:#{method}, *args, &block)
-        rescue Exception
+        rescue ::Exception
           $@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
           ::Kernel::raise
         end
@@ -273,7 +273,7 @@ module SingleForwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L273
       def #{ali}(*args, &block)
         begin
           #{accessor}.__send__(:#{method}, *args, &block)
-        rescue Exception
+        rescue ::Exception
           $@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
           ::Kernel::raise
         end
Index: test/test_forwardable.rb
===================================================================
--- test/test_forwardable.rb	(revision 52248)
+++ test/test_forwardable.rb	(revision 52249)
@@ -94,6 +94,22 @@ class TestForwardable < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/test_forwardable.rb#L94
     end
   end
 
+  class Foo
+    extend Forwardable
+
+    def_delegator :bar, :baz
+
+    class Exception
+    end
+  end
+
+  def test_backtrace_adjustment
+    e = assert_raise(NameError) {
+      Foo.new.baz
+    }
+    assert_not_match(/\/forwardable\.rb/, e.backtrace[0])
+  end
+
   private
 
   def forwardable_class(&block)

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

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