Steven D'Aprano added the comment: Before Python runs your code, it compiles it to byte-code. A SyntaxError means that the code cannot be compiled, and so it does not run.
So the SyntaxError is raised *before* any of the code runs, and standard error is not re-directed. This is expected behaviour, not a bug. You cannot catch compile-time errors at run-time. ---------- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30894> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com