diff options
| author | Georg Brandl <georg@python.org> | 2009-04-05 14:24:52 (GMT) |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2009-04-05 14:24:52 (GMT) |
| commit | dc4a77159b26069ee8a3f67977899f57fd160c3d (patch) | |
| tree | ba4f159e01766cea9a36909e3d7027ab5f500f3b /Lib/traceback.py | |
| parent | 517cfdcfd9261bdaf34d054e3d2416abb9f9f930 (diff) | |
| download | cpython-dc4a77159b26069ee8a3f67977899f57fd160c3d.zip cpython-dc4a77159b26069ee8a3f67977899f57fd160c3d.tar.gz cpython-dc4a77159b26069ee8a3f67977899f57fd160c3d.tar.bz2 | |
#1326077: fix traceback formatting of SyntaxErrors. This fixes two differences with formatting coming from Python: a) the reproduction of location details in the error message if no line text is given, b) the prefixing of the last line by one space.
Diffstat (limited to 'Lib/traceback.py')
| -rw-r--r-- | Lib/traceback.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index b06fcea..86a2c06 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -64,7 +64,7 @@ def print_tb(tb, limit=None, file=None): filename = co.co_filename name = co.co_name _print(file, - ' File "%s", line %d, in %s' % (filename,lineno,name)) + ' 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()) @@ -124,9 +124,8 @@ def print_exception(etype, value, tb, limit=None, file=None): _print(file, 'Traceback (most recent call last):') print_tb(tb, limit, file) lines = format_exception_only(etype, value) - for line in lines[:-1]: - _print(file, line, ' ') - _print(file, lines[-1], '') + for line in lines: + _print(file, line, '') def format_exception(etype, value, tb, limit = None): """Format a stack trace and the exception information. @@ -195,7 +194,7 @@ def format_exception_only(etype, value): caretspace = ((c.isspace() and c or ' ') for c in caretspace) # only three spaces to account for offset1 == pos 0 lines.append(' %s^\n' % ''.join(caretspace)) - value = msg + value = msg lines.append(_format_final_exc_line(stype, value)) return lines |
