[issue7649] "u'%c' % char" broken for chars in range '\x80'-'\xFF'

Amaury Forgeot d'Arc report at bugs.python.org
Wed Feb 24 10:44:02 CET 2010


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

> Could you please check for chars above 0x7f first and then use
> PyUnicode_Decode() instead of the PyUnicode_FromStringAndSize() API

I concur: PyUnicode_FromStringAndSize() decodes with utf-8 whereas the expected conversion char->unicode should use the default encoding (ascii).
But why is it necessary to check for chars above 0x7f?

> (this API should not have been backported from the Python 3.x
> in Python 2.6,
This function is still useful when the chars come from a C string literal in the source code (btw there should be something about the encoding used in C files). But it's not always correctly used even in 3.x, in posixmodule.c for example.

----------
nosy: +amaury.forgeotdarc

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


More information about the Python-bugs-list mailing list