Re: Pyrex Digest, Vol 55, Issue 3

Claudio Freire <[email protected]> Tue, 21 Jul 2009 10:46:46 -0300
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
Answers inline:

> I'd like to know if there's any way to import a pyrex module and still ha=
ve the python interactive interpreter handle errors as before.
>
> For example, normally if I type:
>
>>>> abc
>
> I get a standard NameError, and then another '>>>' line
>
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> NameError: name 'abc' is not defined
>>>>

It always behaved like that for me

> ...but if I first import a pyrex module then I get the same traceback, bu=
t then no '>>>' line. Python just quits.

That would suggest a segmentation fault in your pyrex module. Pyrex,
since it generates native code, is more prone to segfault-resulting
mistakes than Python which is almost always exempt from those. The
simple construct

cdef int a[100]
a[500] =3D 2

Results in an IndexError in Python (if it were to be translated into
pure python), and a segmentation fault in Pyrex. Well, actually I just
tried and it doesn't crash - but I bet it's pure luck, it must be
overwriting vacant memory ;)

In any case, when you code pyrex you code closer to C than to Python,
in that you should be extra careful with memory references.