[issue30496] Incomplete traceback with `exec` on SyntaxError

2017-05-29 Thread Stefan Seefeld
Stefan Seefeld added the comment: 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

[issue30496] Incomplete traceback with `exec` on SyntaxError

2017-05-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: 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

[issue30496] Incomplete traceback with `exec` on SyntaxError

2017-05-29 Thread Stefan Seefeld
Stefan Seefeld added the comment: Answering my own question: 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. --

[issue30496] Incomplete traceback with `exec` on SyntaxError

2017-05-29 Thread Stefan Seefeld
Stefan Seefeld added the comment: Some further experiements: Replacing the `exec(f.read(), env)` line by ``` code = compile(f.read(), 'script', 'exec') exec(code, env) ``` exhibits the same behaviour. If I remove the `try...except`, the correct (full) traceback is printed out. So it looks like

[issue30496] Incomplete traceback with `exec` on SyntaxError

2017-05-29 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- versions: +Python 2.7, Python 3.6, Python 3.7 ___ Python tracker ___

[issue30496] Incomplete traceback with `exec` on SyntaxError

2017-05-29 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- components: +Interpreter Core nosy: +benjamin.peterson, brett.cannon, ncoghlan, yselivanov stage: -> needs patch title: Incomplete traceback with `exec` -> Incomplete traceback with `exec` on SyntaxError