[Pyrex] [Cython-dev] Segmentation Fault with -O0

Robert Bradshaw robertwb at math.washington.edu
Wed Aug 15 18:54:55 CEST 2007


This is precisely what cython does--at the top of the generated c  
file it puts

#if PY_VERSION_HEX < 0x02050000
   typedef int Py_ssize_t;
   #define PY_SSIZE_T_MAX INT_MAX
   #define PY_SSIZE_T_MIN INT_MIN
   #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
   #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
#endif

to be able to handle pre- and post- Python 2.5 without having to  
worry about it.

On Aug 15, 2007, at 9:21 AM, Samuele Kaplun wrote:

> In data mercoledì 15 agosto 2007, Stefan Behnel scribacchiaste  
> dette parole:
>> Samuele Kaplun wrote:
>>
>> Well, have you tried compiling it under Python 2.4? It should work
>> out-of-the-box.
>>
>> Stefan
>
> If I declare with:
> ctypedef int Py_ssize_t in the global space, then it's ok, but I'm  
> not sure
> this makes Python/Pyrex/Gcc happy.
> Otherwise if import Py_ssize_t with:
>
> cdef extern from "Python.h":
>     ctypedef int Py_ssize_t
>
> Then this works only on Python 2.5.
>
> I found a PEP about Py_ssize_t stating that it was introduced after  
> 2.5.0
> So for now I've added a macro in a personal .h header with
>
> #include <Python.h>
> #if PY_VERSION_HEX < 0x02050000
> typedef int Py_ssize_t;
> #endif
>
> and then I import Py_ssize_t from my header.
> Do you think is a proper solution or even the first run should be  
> perfectly
> fine?
> Best regards,
> 	Samuele
>
> -- 
> .O.
> ..O
> OOO
> _______________________________________________
> Cython-dev mailing list
> Cython-dev at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/cython-dev




More information about the Pyrex mailing list