Kaydet (Commit) c54aec1f authored tarafından Facundo Batista's avatar Facundo Batista

Issue 1106316. post_mortem()'s parameter, traceback, is now

optional: it defaults to the traceback of the exception that is currently
being handled.
üst 372d55e3
...@@ -107,9 +107,12 @@ slightly different way: ...@@ -107,9 +107,12 @@ slightly different way:
being debugged (e.g. when an assertion fails). 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() .. function:: pm()
......
...@@ -1198,7 +1198,16 @@ def set_trace(): ...@@ -1198,7 +1198,16 @@ def set_trace():
# Post-Mortem interface # 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 = Pdb()
p.reset() p.reset()
while t.tb_next is not None: while t.tb_next is not None:
......
...@@ -21,6 +21,11 @@ Core and builtins ...@@ -21,6 +21,11 @@ Core and builtins
Library 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 - Issue #1193577: A .shutdown() method has been added to SocketServers
which terminates the .serve_forever() loop. which terminates the .serve_forever() loop.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment