diff options
author | Guido van Rossum <guido@python.org> | 1994-08-23 13:32:20 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-08-23 13:32:20 (GMT) |
commit | 7aeb4b9ce85fa9d15c79bbb3c1ccf6cc31cd5e61 (patch) | |
tree | 4dc519fdd727cc179d5b884ae117871ec02695eb /Lib/traceback.py | |
parent | 9e1e149a5fbb0b24c4f3b7a2cc52e5236a715ee4 (diff) | |
download | cpython-7aeb4b9ce85fa9d15c79bbb3c1ccf6cc31cd5e61.zip cpython-7aeb4b9ce85fa9d15c79bbb3c1ccf6cc31cd5e61.tar.gz cpython-7aeb4b9ce85fa9d15c79bbb3c1ccf6cc31cd5e61.tar.bz2 |
* Lib/linecache.py: don't crash on empty filename
* Lib/macpath.py: don't return trailing colon for dirname()
(XXX won't do for volume names -- but otherwise glob(':*:*.py')
loops forever)
* Lib/traceback.py: print SyntaxError correctly
* Lib/stat.py: moved to posixstat.py; added macstat.py which has
the constants for the Mac; and created new stat.py which includes
the right one
* Lib/urllib.py: fix caching bug (by disabling the cache)
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r-- | Lib/traceback.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index c78d9ad..1eec209 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -42,11 +42,33 @@ def extract_tb(tb, limit = None): return list def print_exception(type, value, tb, limit = None): - print 'Traceback (innermost last):' - print_tb(tb, limit) - print type, - if value is not None: print ':', value, - print + if tb: + print 'Traceback (innermost last):' + print_tb(tb, limit) + if value is None: + print type + else: + if type is SyntaxError: + try: + msg, (filename, lineno, offset, line) = value + except: + pass + else: + if not filename: filename = "<string>" + print ' File "%s", line %d' % (filename, lineno) + i = 0 + while i < len(line) and line[i] in string.whitespace: + i = i+1 + s = ' ' + print s + string.strip(line) + for c in line[i:offset-1]: + if c in string.whitespace: + s = s + c + else: + s = s + ' ' + print s + '^' + value = msg + print '%s: %s' % (type, value) def print_exc(limit = None): print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, |