From: Georg Brandl Date: Sun, 13 Oct 2013 21:34:06 +0000 (+0200) Subject: merge with 3.3 X-Git-Tag: v3.4.0a4~112 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64bed06036e42e6a380ffc9257638d3a40294ecc;p=python merge with 3.3 --- 64bed06036e42e6a380ffc9257638d3a40294ecc diff --cc Lib/traceback.py index d5b37528ba,b13bfe2497..3b2cae748e --- a/Lib/traceback.py +++ b/Lib/traceback.py @@@ -86,11 -50,29 +86,11 @@@ def print_tb(tb, limit=None, file=None) 'file' should be an open file or file-like object with a write() method. """ - if file is None: - file = sys.stderr - if limit is None: - if hasattr(sys, 'tracebacklimit'): - limit = sys.tracebacklimit - n = 0 - while tb is not None and (limit is None or n < limit): - f = tb.tb_frame - lineno = tb.tb_lineno - co = f.f_code - filename = co.co_filename - name = co.co_name - _print(file, - ' File "%s", line %d, in %s' % (filename, lineno, name)) - linecache.checkcache(filename) - line = linecache.getline(filename, lineno, f.f_globals) - if line: _print(file, ' ' + line.strip()) - tb = tb.tb_next - n = n+1 + print_list(extract_tb(tb, limit=limit), file=file) def format_tb(tb, limit=None): - """A shorthand for 'format_list(extract_tb(tb, limit)).""" + """A shorthand for 'format_list(extract_tb(tb, limit))'.""" - return format_list(extract_tb(tb, limit)) + return format_list(extract_tb(tb, limit=limit)) def extract_tb(tb, limit=None): """Return list of up to limit pre-processed entries from traceback.