[Python-Dev] Improvements for Porting C Extension from 2 to 3

Michael Foord fuzzyman at voidspace.org.uk
Thu Mar 3 15:05:21 CET 2011


On 03/03/2011 13:45, Benjamin Peterson wrote:
> 2011/3/3 Sümer Cip<sumerc at gmail.com>:
>>>> 1) define PyModuleDef
>>>> 2) change PyString_AS_STRING calls  to _PyUnicode_AsString
>>> Aside: Please don't use private APIs in Python extensions. Esp.
>>> the above Unicode API is likely going to be phased out.
>>>
>>> You're better off, using PyUnicode_AsUTF8String() instead and
>>> then leaving the PyString_AS_STRING() macro in place.
>> In the standart Python 3.2 source tree, Modules/_lsprof.c uses that internal
>> function _PyUnicode_AsString. Internal means internal to the whole
>> distribution here I think?. But IMHO, this should not be the case, C API
>> modules in the standart dist. should not use internal functions of other
>> areas. Like in the example: cProfile code has nothing to do with the Unicode
>> internals. New developers like me, are in need a consistent examples of
>> usage of Python C API, especially on Python 3.2.
> I'm not sure why what C-API is used in Python's extension modules
> needs to be anyway to you.
>
I think its fair enough to point out the inconsistency in python-dev 
declaring that authors *should not* use certain parts of the C-API in 
extensions whilst using them in the extensions python-dev is responsible 
for...

Michael

-- 
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html



More information about the Python-Dev mailing list