diff -r 178d4ffe1249 -r 9f618a0c2880 Lib/traceback.py --- a/Lib/traceback.py Sun Oct 12 16:13:38 2014 +0200 +++ b/Lib/traceback.py Sun Oct 12 16:31:14 2014 +0000 @@ -3,6 +3,7 @@ import linecache import sys import operator +import types __all__ = ['extract_stack', 'extract_tb', 'format_exception', 'format_exception_only', 'format_list', 'format_stack', @@ -51,8 +52,14 @@ # - Next item (same type as curr) # In practice, curr is either a traceback or a frame. def _extract_tb_or_stack_iter(curr, limit, extractor): + # Distinguish frames from tracebacks (need to import types) if limit is None: limit = getattr(sys, 'tracebacklimit', None) + elif limit < 0 and isinstance(curr, types.TracebackType): + seq = list(_extract_tb_or_stack_iter(curr, None, extractor)) + yield from seq[limit:] + else: + pass n = 0 while curr is not None and (limit is None or n < limit):