Amaury Forgeot d'Arc <amaur...@gmail.com> added the comment: This also happens on a Western Windows (cp437, mbcs==cp1252) with a filename like "café.py".
The attached patch corrects three problems: - in compile.c, the c_filename member has utf8 encoding, and must not be decoded with PyUnicode_DecodeFSDefault. This is the reported issue. - Same thing in pythonrun.c, if you want "print(__file__)" to work. - in traceback.c, the content of the file is not shown. Tested with this script: ===================================================== print("file name:", __file__) import traceback try: aaa except: traceback.print_exc() raise ===================================================== The output should be: ===================================================== file name: c:\temp\café.py Traceback (most recent call last): File "c:\temp\café.py", line 4, in <module> aaa NameError: name 'aaa' is not defined Traceback (most recent call last): File "c:\temp\café.py", line 4, in <module> aaa NameError: name 'aaa' is not defined ===================================================== ---------- keywords: +patch nosy: +amaury.forgeotdarc Added file: http://bugs.python.org/file14538/traceback-encoding.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6543> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com