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

ruby-changes:4257

From: ko1@a...
Date: Tue, 11 Mar 2008 17:04:03 +0900 (JST)
Subject: [ruby-changes:4257] nobu - Ruby:r15747 (ruby_1_8, trunk): * lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct

nobu	2008-03-11 17:03:26 +0900 (Tue, 11 Mar 2008)

  New Revision: 15747

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/lib/delegate.rb
    trunk/ChangeLog

  Log:
    * lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct
      backtrace.  [ruby-dev:34019]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=15747&r2=15746&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15747&r2=15746&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/delegate.rb?r1=15747&r2=15746&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15746)
+++ ChangeLog	(revision 15747)
@@ -1,3 +1,8 @@
+Tue Mar 11 17:03:23 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct
+	  backtrace.  [ruby-dev:34019]
+
 Tue Mar 11 12:39:53 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (clean-local): WINMAINOBJ is Windows specific.
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 15746)
+++ ruby_1_8/ChangeLog	(revision 15747)
@@ -1,3 +1,8 @@
+Tue Mar 11 17:03:23 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct
+	  backtrace.  [ruby-dev:34019]
+
 Tue Mar 11 16:43:53 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* win32/win32.c (rb_w32_cmdvector): terminate shrunken command line.
Index: ruby_1_8/lib/delegate.rb
===================================================================
--- ruby_1_8/lib/delegate.rb	(revision 15746)
+++ ruby_1_8/lib/delegate.rb	(revision 15747)
@@ -115,6 +115,7 @@
 # implementation, see SimpleDelegator.
 #
 class Delegator
+  IgnoreBacktracePat = %r"\A#{Regexp.quote(__FILE__)}:\d+:in `"
 
   #
   # Pass in the _obj_ to delegate method calls to.  All methods supported by
@@ -133,14 +134,12 @@
     for method in obj.methods
       next if preserved.include? method
       begin
-	eval <<-EOS
+	eval <<-EOS, nil, __FILE__, __LINE__+1
 	  def self.#{method}(*args, &block)
 	    begin
 	      __getobj__.__send__(:#{method}, *args, &block)
-	    rescue Exception
-	      $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #`
-	      $@.delete_if{|s| /^\\(eval\\):/ =~ s}
-	      Kernel::raise
+	    ensure
+	      $@.delete_if{|s|IgnoreBacktracePat=~s}
 	    end
 	  end
 	EOS
@@ -291,13 +290,12 @@
   }
   for method in methods
     begin
-      klass.module_eval <<-EOS
+      klass.module_eval <<-EOS, __FILE__, __LINE__+1
         def #{method}(*args, &block)
 	  begin
 	    @_dc_obj.__send__(:#{method}, *args, &block)
-	  rescue
-	    $@[0,2] = nil
-	    raise
+	  ensure
+	    $@.delete_if{|s| ::Delegator::IgnoreBacktracePat =~ s}
 	  end
 	end
       EOS

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

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