Author Timothy McCurrach
Recipients Timothy McCurrach
Date 2018-08-22.19:01:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1534964466.61.0.56676864532.issue34463@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-08-22 19:01:06Timothy McCurrachsetrecipients: + Timothy McCurrach
2018-08-22 19:01:06Timothy McCurrachsetmessageid: <1534964466.61.0.56676864532.issue34463@psf.upfronthosting.co.za>
2018-08-22 19:01:06Timothy McCurrachlinkissue34463 messages
2018-08-22 19:01:06Timothy McCurrachcreate