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.

classification
Title: Windows: use (mbcs in) strict mode to encode/decode filenames, and enable os.fsencode()
Type: Stage:
Components: Interpreter Core, Library (Lib), Unicode, Windows Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lemburg, loewis, vstinner
Priority: normal Keywords: patch

Created on 2010-06-11 00:33 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fsencode_mbcs.patch vstinner, 2010-06-11 00:33
Messages (2)
msg107510 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-11 00:33
mbcs encoding doesn't support surrogateescape (see #850997), and mbcs should only be used in strict mode to encode/decode filenames.

os.fsencode() should also be enabled on Windows. First I tried to disable this function on Windows to avoid the evil mbcs encoding, but mbcs encoding *is* used by some modules written in C (functions using PyUnicode_FSConverter(): encode the filename to bytes with mbcs encoding on Windows). Eg. _ssl module use PyUnicode_FSConverter() to get filenames because the underlying library, OpenSSL, requires bytes for the filenames (C type: char*). Enable os.fsencode() on Windows helps some tests (eg. fix test_ssl).

Use "strict" error handler, instead of "surrogateescape", to encode/decode filenames with mbcs encoding, does nothing yet because mbcs codec ignore the errors argument. These changes prepare the work on mbcs codec: see #850997.

Note: os.fsencode() was introduced by #8514.
msg107610 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-11 23:57
Patch commited as r81927 (3.2).
History
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53215
2010-06-13 21:16:11vstinnersetstatus: open -> closed
resolution: fixed
2010-06-11 23:57:26vstinnersetmessages: + msg107610
2010-06-11 00:33:51vstinnersetnosy: + lemburg, loewis
2010-06-11 00:33:06vstinnercreate