[Pyrex] Pyrex Digest, Vol 55, Issue 3
Claudio Freire
klaussfreire at gmail.com
Tue Jul 21 15:46:46 CEST 2009
Answers inline:
> I'd like to know if there's any way to import a pyrex module and still have 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, but 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] = 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.
More information about the Pyrex
mailing list