[Python-checkins] r61312 - in python/trunk: Doc/library/pdb.rst Lib/pdb.py Misc/NEWS

facundo.batista python-checkins at python.org
Sat Mar 8 17:50:27 CET 2008


Author: facundo.batista
Date: Sat Mar  8 17:50:27 2008
New Revision: 61312

Modified:
   python/trunk/Doc/library/pdb.rst
   python/trunk/Lib/pdb.py
   python/trunk/Misc/NEWS
Log:

Issue 1106316. post_mortem()'s parameter, traceback, is now
optional: it defaults to the traceback of the exception that is currently
being handled.


Modified: python/trunk/Doc/library/pdb.rst
==============================================================================
--- python/trunk/Doc/library/pdb.rst	(original)
+++ python/trunk/Doc/library/pdb.rst	Sat Mar  8 17:50:27 2008
@@ -107,9 +107,12 @@
    being debugged (e.g. when an assertion fails).
 
 
-.. function:: post_mortem(traceback)
+.. function:: post_mortem([traceback])
 
-   Enter post-mortem debugging of the given *traceback* object.
+   Enter post-mortem debugging of the given *traceback* object.  If no 
+   *traceback* is given, it uses the one of the exception that is currently
+   being handled (an exception must be being handled if the default is to be
+   used).
 
 
 .. function:: pm()

Modified: python/trunk/Lib/pdb.py
==============================================================================
--- python/trunk/Lib/pdb.py	(original)
+++ python/trunk/Lib/pdb.py	Sat Mar  8 17:50:27 2008
@@ -1198,7 +1198,16 @@
 
 # Post-Mortem interface
 
-def post_mortem(t):
+def post_mortem(t=None):
+    # handling the default
+    if t is None:
+        # sys.exc_info() returns (type, value, traceback) if an exception is
+        # being handled, otherwise it returns None
+        t = sys.exc_info()[2]
+        if t is None:
+            raise ValueError("A valid traceback must be passed if no "
+                                               "exception is being handled")
+
     p = Pdb()
     p.reset()
     while t.tb_next is not None:

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sat Mar  8 17:50:27 2008
@@ -21,6 +21,11 @@
 Library
 -------
 
+- Issue #1106316: pdb.post_mortem()'s parameter, "traceback", is now
+  optional: it defaults to the traceback of the exception that is currently
+  being handled (is mandatory to be in the middle of an exception, otherwise
+  it raises ValueError).
+
 - Issue #1193577: A .shutdown() method has been added to SocketServers
   which terminates the .serve_forever() loop.
 


More information about the Python-checkins mailing list