summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-06 03:02:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-06 03:02:40 +0000
commita6569ad637e46eeb93bd28fe1ffe3c173dc43903 (patch)
treeef22087261445945a2cf696d7b50b3ae8621a5c8
parent26b8c0890f4177f004b40adaad1a412e3f22cb72 (diff)
* lib/delegate.rb (Delegator#method_missing),
(Delegator.delegating_block): don't hide backtrace from __getobj__ and reduced exception messages when $DEBUG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/delegate.rb24
2 files changed, 14 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index d5139eab9c3..19b6ba129fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Feb 6 12:02:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/delegate.rb (Delegator#method_missing),
+ (Delegator.delegating_block): don't hide backtrace from
+ __getobj__ and reduced exception messages when $DEBUG.
+
Sat Feb 6 11:35:08 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/ipsocket.c (ip_addr, ip_peeraddr),
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 0d5dc23b6e4..2891167fa84 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -139,18 +139,11 @@ class Delegator < BasicObject
# Handles the magic of delegation through \_\_getobj\_\_.
def method_missing(m, *args, &block)
+ target = self.__getobj__
begin
- target = self.__getobj__
- unless target.respond_to?(m)
- super(m, *args, &block)
- else
- target.__send__(m, *args, &block)
- end
- rescue ::Exception
- if i = $@.index{|s| %r"\A#{Regexp.quote(__FILE__)}:\d+:in `method_missing'\z"o =~ s}
- $@[0..i] = []
- end
- ::Kernel::raise
+ target.respond_to?(m) ? target.__send__(m, *args, &block) : super(m, *args, &block)
+ ensure
+ $@.delete_if {|t| %r"\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:"o =~ t} if $@
end
end
@@ -267,12 +260,11 @@ end
# :stopdoc:
def Delegator.delegating_block(mid)
lambda do |*args, &block|
+ target = self.__getobj__
begin
- __getobj__.__send__(mid, *args, &block)
- rescue
- re = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:/o
- $!.backtrace.delete_if {|t| re =~ t}
- raise
+ target.__send__(mid, *args, &block)
+ ensure
+ $@.delete_if {|t| /\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:/o =~ t} if $@
end
end
end