Index: Lib/traceback.py =================================================================== --- Lib/traceback.py (revision 83379) +++ Lib/traceback.py (working copy) @@ -135,7 +135,8 @@ yield x -def print_exception(etype, value, tb, limit=None, file=None, chain=True): +def print_exception(etype, value, tb, limit=None, file=None, chain=True, + fullstack=False): """Print exception up to 'limit' stack trace entries from 'tb' to 'file'. This differs from print_tb() in the following ways: (1) if @@ -144,7 +145,9 @@ stack trace; (3) if type is SyntaxError and value has the appropriate format, it prints the line where the syntax error occurred with a caret on the next line indicating the approximate - position of the error. + position of the error (4) if fullstack is True it prefixes the + traceback with the print_stack, thus giving a 'full' traceback from + the top of the interpreter stack. """ if file is None: file = sys.stderr @@ -152,12 +155,21 @@ values = _iter_chain(value, tb) else: values = [(value, tb)] + if fullstack and tb.tb_frame.f_back: + _print(file, 'Traceback (most recent call last):') + print_stack(tb.tb_frame.f_back, file=file) + printheader = False + else: + printheader = True for value, tb in values: if isinstance(value, str): _print(file, value) continue if tb: - _print(file, 'Traceback (most recent call last):') + if printheader: + _print(file, 'Traceback (most recent call last):') + else: + printheader = True print_tb(tb, limit, file) lines = format_exception_only(type(value), value) for line in lines: