Rémi Lapeyre <remi.lape...@henki.fr> added the comment: Indeed, the exception has the correct line number when compiling manually:
>>> try: ... compile('if __name__ == "__main__":\n print("hello world"\n', '<string>', 'exec') ... except SyntaxError as e: ... print(e.lineno) ... 2 but not when running `python3 main.py`: File "main.py", line 3 ^ SyntaxError: unexpected EOF while parsing I tried with all version of Python >= 3.6 and Python2 and they all exhibit the same behavior. ---------- nosy: +remi.lapeyre versions: +Python 3.10, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40813> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com