[Python-checkins] python/nondist/peps pep-0344.txt,1.6,1.7

ping@users.sourceforge.net ping at users.sourceforge.net
Mon May 16 21:12:55 CEST 2005


Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17533

Modified Files:
	pep-0344.txt 
Log Message:
Simplify implementation of print_chain.


Index: pep-0344.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0344.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- pep-0344.txt	16 May 2005 07:10:22 -0000	1.6
+++ pep-0344.txt	16 May 2005 19:12:51 -0000	1.7
@@ -295,20 +295,13 @@
     or __context__ respectively.  Here is a sketch of the procedure:
     
         def print_chain(exc):
-            chain = []
-            link = None
-            while exc:
-                chain.append((exc, link))
-                if exc.__cause__:
-                    exc, link = exc.__cause__, 'The above exception...'
-                else:
-                    exc, link = exc.__context__, 'During handling...'
-            for exc, link in reversed(chain):
-                print_exc(exc)
-                if link:
-                    print
-                    print link
-                    print
+            if exc.__cause__:
+                print_chain(exc.__cause__)
+                print '\nThe above exception was the direct cause...'
+            elif exc.__context__:
+                print_chain(exc.__context__)
+                print '\nDuring handling of the above exception, ...'
+            print_exc(exc)
 
     In the 'traceback' module, the format_exception, print_exception,
     print_exc, and print_last functions will be updated to accept an



More information about the Python-checkins mailing list