[New-bugs-announce] [issue34463] Discrepancy between traceback.print_exception and sys.__excepthook__
Timothy McCurrach
report at bugs.python.org
Wed Aug 22 15:01:06 EDT 2018
New submission from Timothy McCurrach <tim.mccurrach at gmail.com>:
If you have set sys.excepthook to some function which calls traceback.print_exception, then I would expect to get identical traceback/exception messages. If you run raise SyntaxError("some message"), then print_exception has the extra line `File "<string>", line None`.
This comes from lines 558-561 of traceback.py:
# It was a syntax error; show exactly where the problem was found.
filename = self.filename or "<string>"
lineno = str(self.lineno) or '?'
yield ' File "{}", line {}\n'.format(filename, lineno)
Is it expected behaviour that these two functions behave differently, or should there be something like:
if self.filename or self.lineno:
etc.
Also, if self.lineno is None, then str(self.lineno) evaluates to "None" and so the ? is never used.
----------
components: Demos and Tools
messages: 323902
nosy: Timothy McCurrach
priority: normal
severity: normal
status: open
title: Discrepancy between traceback.print_exception and sys.__excepthook__
type: behavior
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34463>
_______________________________________
More information about the New-bugs-announce
mailing list