This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Python can't run .pyc files with non-ASCII path on Windows
Type: behavior Stage: resolved
Components: Interpreter Core, Windows Versions: Python 3.10, Python 3.9, Python 3.8
Status: closed Resolution: duplicate
Dependencies: Superseder: Python 3.6 cannot reopen .pyc file with non-ASCII path
View: 32381
Assigned To: Nosy List: izbyshev, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords:

Created on 2020-12-04 15:03 by izbyshev, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (1)
msg382490 - (view) Author: Alexey Izbyshev (izbyshev) * (Python triager) Date: 2020-12-04 15:03
> python тест.pyc
python: Can't reopen .pyc file

The issue is caused by _Py_fopen() being used as though it can deal with paths encoded in FS-default encoding (UTF-8 by default on Windows), but in fact it's just a simple wrapper around fopen() from the C runtime, so it uses the current ANSI code page, breaking if PYTHONLEGACYWINDOWSFSENCODING is not enabled.

I could find only two callers if _Py_fopen() on Windows:

* (which caused this issue)


PyErr_ProgramText() doesn't seem to be called in CPython, but claims that filename is "decoded from the filesystem encoding", which doesn't match the code.
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86734
2020-12-04 15:24:00eryksunsetstatus: open -> closed
superseder: Python 3.6 cannot reopen .pyc file with non-ASCII path
resolution: duplicate
stage: resolved
2020-12-04 15:03:14izbyshevcreate