Hi,

After attempted all the hacks come from my mind, I solved the unicode
string to const char* conversion problem by simply calling a Python
C-API: _PyUnicode_AsString. Since it is start with an underscore, it
is not a public API and not documented. But I wonder why it is not
documented, as it's really a useful API. PyUnicode manages a PyBytes
object as the cached encoded string, and _PyUnicode_AsString will
return the lvalue inside the encoded string. So we don't need anything
for lifetime management in our code, this API will keep the same
semantic as PyString_AsString.

Now most of the test cases are passed. Just some corner things
remaining, and it seems there is a 2to3 bug caused some doctests
syntax not fixed. I'm going to take care of these.

Regards,
Haoyu Bai
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to