[New-bugs-announce] [issue11619] On Windows, don't encode filenames in the import machinery

STINNER Victor report at bugs.python.org
Mon Mar 21 00:58:51 CET 2011

New submission from STINNER Victor <victor.stinner at haypocalc.com>:

With #3080, Python 3.3 does now manipulate module paths and names as Unicode in the import machinery. But in 3 remaining places, it does encode filenames (to the ANSI code page):

a) _PyImport_LoadDynamicModule()

It should pass directly the PyObject* (instead of a char*) to _PyImport_GetDynLoadFunc(), but only on Windows (we may change the function name for Windows). _PyImport_GetDynLoadFunc() of dynload_win.c has to be patched to use the Unicode API (eg. LoadLibraryEx => LoadLibraryExW).

b) write_compiled_module()

The problem is to implement open_exclusive() for Windows using Unicode. open_exclusive() uses open() on Windows, but open() expects the filename as a byte string. We may use _Py_fopen() (_wfopen), but this function doesn't have an option to open the file in exclusive mode (O_EXCL flag). GNU has an extension: "x" flag in the file mode, but Windows doesn't support it.

The file is passed to marshal functions like PyMarshal_WriteLongToFile(), and so the file have to be a FILE*.

c) parse_source_module()

=> covered by the issue #10785.

components: Interpreter Core, Unicode, Windows
messages: 131574
nosy: amaury.forgeotdarc, haypo, pitrou
priority: normal
severity: normal
status: open
title: On Windows, don't encode filenames in the import machinery
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list