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
标题: Windows: use (mbcs in) strict mode to encode/decode filenames, and enable os.fsencode()
类型: Stage:
Components: Interpreter Core, Library (Lib), Unicode, Windows Versions: Python 3.2
process
状态: closed Resolution: fixed
Dependencies: 后续:
分配给: 抄送列表: lemburg, loewis, vstinner
优先级: normal 关键字: patch

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

文件
文件名 上传时间 Description 编辑
fsencode_mbcs.patch vstinner, 2010-06-11 00:33
Messages (2)
msg107510 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 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) 日期: 2010-06-11 23:57
Patch commited as r81927 (3.2).
历史
日期 用户 动作 参数
2022-04-11 14:57:02admin修改github: 53215
2010-06-13 21:16:11vstinner修改状态: open -> closed
resolution: fixed
2010-06-11 23:57:26vstinner修改消息: + msg107610
2010-06-11 00:33:51vstinner修改抄送: + lemburg, loewis
2010-06-11 00:33:06vstinner创建