You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exhibits the same behaviour. If I remove the try...except, the correct
(full) traceback is printed out. So it looks like the issue is with the traceback propagation through exception handlers when the error happens during parsing.
It appears I can get the location of a syntax error by inspecting the
raised SyntaxError, which solves my specific use-case.
The bug remains, though: The traceback is incomplete if it stems from a syntax error.
The traceback contain the location of the code that raised an exception when executed. In case of NameError this is a line in your script "x=u". In case of SyntaxError the code that failed is not in your script (it still is not executed), but in a compiler implicitly called by exec(). The line with exec() is correctly reported.
OK, fair enough, that makes sense. As I said, in my last message, I was mainly simply trying to figure out the exact location of the error in the executed script, which I got from inspecting the SyntaxError.
So if all of this is expected behaviour, I think we can close this issue.