* 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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2015-10-23 15:41:04 +00:00
parent f8a83d8563
commit 8c8e17d499
3 changed files with 25 additions and 2 deletions

View File

@ -1,3 +1,10 @@
Sat Oct 24 00:38:34 2015 Shugo Maeda <shugo@ruby-lang.org>
* 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@ruby-lang.org>
* error.c (name_err_mesg_to_str): separate class names from the

View File

@ -181,7 +181,7 @@ module Forwardable
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
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

View File

@ -94,6 +94,22 @@ class TestForwardable < Test::Unit::TestCase
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)