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

2011-03-03 Thread Alexander Belopolsky
On Thu, Mar 3, 2011 at 9:05 AM, Michael Foord wrote: .. > 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... This is not a

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

2011-03-03 Thread Michael Foord
On 03/03/2011 13:45, Benjamin Peterson wrote: 2011/3/3 Sümer Cip: 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 Py

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

2011-03-03 Thread Sümer Cip
> > I'm not sure why what C-API is used in Python's extension modules > needs to be anyway to you. > I just tought it is a better programming practice to decrease/narrow inter modular usage of functions inside the whole dist. and also a good example for the other 3rd party C Extension developers.

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

2011-03-03 Thread Benjamin Peterson
2011/3/3 Sümer Cip : > >> > >> > 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_AsUTF8Stri

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

2011-03-03 Thread Sümer Cip
> > > > 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

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

2011-03-03 Thread Victor Stinner
Le jeudi 03 mars 2011 à 11:06 +0200, Sümer Cip a écrit : > While porting a C extension from 2 to 3, I realized that there are some > general cases which can be automated. For example, for my specific > application (yappi - http://code.google.com/p/yappi/), all I need to do is > following things: S

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

2011-03-03 Thread M.-A. Lemburg
Sümer Cip wrote: > Hi, > > While porting a C extension from 2 to 3, I realized that there are some > general cases which can be automated. For example, for my specific > application (yappi - http://code.google.com/p/yappi/), all I need to do is > following things: > > 1) define PyModuleDef > 2) c

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

2011-03-03 Thread Sümer Cip
Hi, While porting a C extension from 2 to 3, I realized that there are some general cases which can be automated. For example, for my specific application (yappi - http://code.google.com/p/yappi/), all I need to do is following things: 1) define PyModuleDef 2) change PyString_AS_STRING calls to