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.

Author izbyshev
Recipients izbyshev, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2020-12-04.15:03:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607094194.36.0.301843698023.issue42568@roundup.psfhosted.org>
In-reply-to
Content
> 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:

* https://github.com/python/cpython/blob/db68544122f5/Python/pythonrun.c#L380 (which caused this issue)

* https://github.com/python/cpython/blob/db68544122f5/Python/errors.c#L1708

PyErr_ProgramText() doesn't seem to be called in CPython, but https://github.com/python/cpython/blob/db68544122f5/Include/pyerrors.h#L243 claims that filename is "decoded from the filesystem encoding", which doesn't match the code.
History
Date User Action Args
2020-12-04 15:03:14izbyshevsetrecipients: + izbyshev, paul.moore, vstinner, tim.golden, zach.ware, steve.dower
2020-12-04 15:03:14izbyshevsetmessageid: <1607094194.36.0.301843698023.issue42568@roundup.psfhosted.org>
2020-12-04 15:03:14izbyshevlinkissue42568 messages
2020-12-04 15:03:13izbyshevcreate