New submission from Timothy McCurrach <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue34463>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com