Amaury Forgeot d'Arc <amaur...@gmail.com> added the comment:

The patch uses the ANSI version, and converts the filename from unicode to 
bytes; this will fail for names that cannot be encoded with the "mbcs" codec.

All other functions in the posix module first try the Wide version of the win32 
API, and use the ANSI version as a fallback, when the argument is a bytes 
string. PyUnicode_FSConverter should be avoided on Windows. See posix_mkdir() 
for a good example.

Here is an example that fails on a Western Windows (where ANSI=cp1252).  Note 
that even the file name is not encodable in mbcs, it is correctly displayed in 
the Explorer for example.

>>> name = "\u65e5\u672c"     # "Japan"
>>> open(name, "w").close()   # Appears correctly in the explorer
>>> import os
>>> os.link(name, name + "_1")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: 
invalid character

----------
nosy: +amaury.forgeotdarc
status: closed -> open

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8879>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to