[Pyrex] cdef object in cdef class: Segmentation fault

Paul Prescod paul at prescod.net
Wed Jan 14 08:27:07 CET 2004


Simon Burton wrote:

> Yes, this is the technique I have tried. Also, I have seen other code examples similar to yours.

Make sure that you are using the same version of Python for making and 
running. Other than that I can't reproduce your problem (using distutils 
on Darwin).

bash-2.05a$ touch bomber.pyx
bash-2.05a$ python Setup.py build_ext --inplace
running build_ext
building 'bomber' extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp 
-mno-fused-madd -DNDEBUG -g -O3 -Wall -Wstrict-prototypes 
-I/Users/pprescod/data/code/Python-2.3.2/Include 
-I/Users/pprescod/data/code/Python-2.3.2 -c bomber.c -o 
build/temp.darwin-6.8-Power_Macintosh-2.3/bomber.o
bomber.c: In function `__pyx_f_6bomber_6Bomber___init__':
bomber.c:63: warning: label `__pyx_L1' defined but not used
... etc...
bomber.c:23: warning: `__Pyx_GetVtable' declared `static' but never defined
gcc -bundle -bundle_loader python.exe 
build/temp.darwin-6.8-Power_Macintosh-2.3/bomber.o -o bomber.so
bash-2.05a$ python
Python 2.3.2 (#1, Dec 12 2003, 20:02:47)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import bomber
 >>> bomber.b
<bomber.Bomber object at 0x479650>
 >>> bomber.Bomber("abc")
<bomber.Bomber object at 0x4799f0>
 >>> print open("Bomber.pyx").read()
cdef class Bomber:
    cdef object handle
    def __init__(self,name):
      self.handle = name

b = Bomber("some")


 >>> print open("setup.py").read()
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
import glob, sys

setup(
   name = 'callback',
   ext_modules=[
     Extension("bomber", ["bomber.pyx"])],
   cmdclass = {'build_ext': build_ext}
)

 >>>






More information about the Pyrex mailing list