[issue20042] Python Launcher for Windows fails to invoke scripts with non-latin names
STINNER Victor
report at bugs.python.org
Sat Dec 21 15:19:50 CET 2013
STINNER Victor added the comment:
It looks like the wide character strings (wchar_t*) are misused. For example:
error(RC_NO_PYTHON, L"Requested Python version (%s) ...", &p[1]);
fwprintf(stdout, L"usage: %s ...\n\n", argv[0]);
The %s formatter is for byte string (char*), "%ls" should be used instead.
+ _setmode(_fileno(stdout), _O_WTEXT);
Extract of wprintf() documentation:
"The wprintf() and vwprintf() functions perform wide-character output to stdout. stdout must not be byte oriented; see fwide(3) for more information."
So _setmode() or fwide() should be used if I understood correctly. Or wprintf() should be replaced with printf() (still with "%ls" format)?
wprintf("%ls") replaces unencodable character string arguments by ? (U+003F), whereas printf("%ls") and wprintf("%s") truncates the output at the first undecodable/unencodable character:
http://unicodebook.readthedocs.org/en/latest/programming_languages.html#printf-functions-family
So wprintf() is probably better here.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20042>
_______________________________________
More information about the Python-bugs-list
mailing list