[Bf-committers] Usage of PyUnicode_FromString() in blender 2.50

Yomgui yomgui1 at gmail.com
Mon Dec 7 10:44:48 CET 2009


Hi,

I've seen in many places that the Python function PyUnicode_FromString
(and similar) is used to convert system strings like argv[] and IO
pathname.

If we look at the Python 3.1 documentation
(http://docs.python.org/3.1/c-api/unicode.html?highlight=pyunicode_fromstring#PyUnicode_FromString)
this function supposes that the input string is UTF-8 encoded.
That's not a strict rule for all OS. This function should be reserved
to pass string for runtime usage like if it was given in a script, but
not for OS/IO strings.

A better (I know... with just more arguments) function to convert
system strings is PyUnicode_Decode()
and use as encoding parameter: Py_FileSystemDefaultEncoding

Thanks.


More information about the Bf-committers mailing list