[issue4388] test_cmd_line fails on MacOS X

STINNER Victor report at bugs.python.org
Thu Oct 14 01:31:44 CEST 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> This issue should be fixed by r85435 ... 
> I will watch for the OSX buildbots.

I don't know if it fixes the issue, but it introduces a regression. r85442 reverts it.

---

Revert r85435 (and r85440): decode command line arguments from utf-8

Python exits with a fatal error if the command line contains an undecodable argument. PyUnicode_FromString() fails at the first undecodable byte because it calls the error handler, but error handlers are not ready before Python initialization.

---

The problem is to get a function to decode a bytes string from utf-8 in main() (before Python initialization). Possibilities:
 - Use PyUnicode_DecodeUTF8Stateful() and tell it to not call the error handler but exit immediatly (return NULL). Eg. check a flag (function argument or global variable?) to check if we should call the error handler or not
 - Use _Py_char2wchar() and set temporary the locale to an utf-8 locale. The problem is to get an utf-8 locale. Is there an utf-8 locale which is always available?
 - Another solution?

I prefer the _Py_char2wchar() solution because I'm sure that it works before Python initialization.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4388>
_______________________________________


More information about the Python-bugs-list mailing list