diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-06-10 18:58:26 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-06-10 18:58:26 (GMT) |
commit | 0bb580d297bdc6ccb33fcd15e317a79112e77750 (patch) | |
tree | 8d119d7ac6a5aa063eee3c211f44f78e67044f3c /Lib/traceback.py | |
parent | 07c1922b12ae56dc892672d02f95e7521e1b8d55 (diff) | |
download | cpython-0bb580d297bdc6ccb33fcd15e317a79112e77750.zip cpython-0bb580d297bdc6ccb33fcd15e317a79112e77750.tar.gz cpython-0bb580d297bdc6ccb33fcd15e317a79112e77750.tar.bz2 |
SF bug 431772: traceback.print_exc() causes traceback
Patch from Michael Hundson.
format_exception_only() blew up when trying to report a SyntaxError
from a string input (line is None in this case, but it assumed a string).
Bugfix candidate.
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r-- | Lib/traceback.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index a758349..70b1606 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -171,19 +171,20 @@ def format_exception_only(etype, value): if not filename: filename = "<string>" list.append(' File "%s", line %d\n' % (filename, lineno)) - i = 0 - while i < len(line) and line[i].isspace(): - i = i+1 - list.append(' %s\n' % line.strip()) - if offset is not None: - s = ' ' - for c in line[i:offset-1]: - if c.isspace(): - s = s + c - else: - s = s + ' ' - list.append('%s^\n' % s) - value = msg + if line is not None: + i = 0 + while i < len(line) and line[i].isspace(): + i = i+1 + list.append(' %s\n' % line.strip()) + if offset is not None: + s = ' ' + for c in line[i:offset-1]: + if c.isspace(): + s = s + c + else: + s = s + ' ' + list.append('%s^\n' % s) + value = msg s = _some_str(value) if s: list.append('%s: %s\n' % (str(stype), s)) |