Author vstinner
Recipients brian.curtin, eric.smith, georg.brandl, jason.coombs, loewis, nadeem.vawda, ocean-city, santoso.wijaya, tim.golden, vstinner
Date 2011-06-07.11:47:28
SpamBayes Score 8.9373e-14
Marked as misclassified No
Message-id <1307447249.58.0.435099561518.issue12084@psf.upfronthosting.co.za>
In-reply-to
Content
Oh oh. The situation is not a simple as expected. 3 functions only accept Unicode strings and 3 other functions decode "manually" byte strings from the ANSI code page.

--

chdir(), rmdir(), unlink(), access(), chmod(), link(), listdir(), _getfullpath(), mkdir(), utime(), open(), startfile(), unlink(), stat() and lstat() use the ANSI or the wide character API depending on the type of the input arguments.

rename(), symlink() and putenv() only use the wide character API. They use convert_to_unicode() to convert input arguments to Unicode. Byte strings are decoded from the file system encoding using the strict error error.

system(), readlink() and unsetenv() only accept Unicode strings.

--

Possible bugs.

unlink() uses DeleteFileA() for byte string and Py_DeleteFileW() for unicode. Py_DeleteFileW() has a special case for symbolic links:

/* override the default DeleteFileW behavior so that directory
symlinks can be removed with this function, the same as with
Unix symlinks */

unsetenv() encodes the variable name to UTF-8, which looks wrong to me.

startfile() encodes the second argument (operation) to UTF-8 and then decode it from ASCII to get a wchar_t* string. Why not using simply the "u" format to support more than ASCII characters?

It's surprising that unsetenv() only accept Unicode strings, because this Python function uses a C function with a bytes API (unsetenv).
History
Date User Action Args
2011-06-07 11:47:29vstinnersetrecipients: + vstinner, loewis, georg.brandl, jason.coombs, ocean-city, eric.smith, tim.golden, nadeem.vawda, brian.curtin, santoso.wijaya
2011-06-07 11:47:29vstinnersetmessageid: <1307447249.58.0.435099561518.issue12084@psf.upfronthosting.co.za>
2011-06-07 11:47:28vstinnerlinkissue12084 messages
2011-06-07 11:47:28vstinnercreate