[issue9713] Py_CompileString fails on non decode-able paths.
report at bugs.python.org
Wed Sep 1 00:29:52 CEST 2010
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
The problem is not specific to Py_CompileString(): all functions based (indirectly) on PyParser_ASTFromString() and PyParser_ASTFromFile() expect filenames encoded in utf-8 with the strict error handler.
If we choose to use something else than utf-8 in strict mode, here is an incomplete list of functions that have to be patched:
And the list of impacted functions (parsing functions accepting filenames):
- PyParser_ASTFromString(), PyParser_ASTFromFile()
All these functions are public and I don't think that it would be a good idea to change the encoding (eg. to iso-8859-1). We can use a different error handler (especially surrogateespace, as suggested in the initial message) and/or create new functions accepting unicode filenames.
I'm working on undecodable filenames in issues #8611 and #9425, especially on the import machinery part. When the import machinery will be fully unicode compliant, the last part will be the "parser machinery" (Parser/*.c). It is a little bit more complex to patch the parser because there is the bootstrap problem: the parser is compiled twice, once with a small subset of the C Python API (using some mockups), once with the full API.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list