[Cython] Fwd: [issue3443] crash on badly initialised AttributeError

Stefan Behnel stefan_ml at behnel.de
Sun Jul 27 09:19:59 CEST 2008


Amaury Forgeot d'Arc wrote:
> After some researches, I think that the problem is in Cython. Cython
> tries to simulate a python frame without using the interpreter loop.
> But at least an invariant is not respected: when a frame exits without
> an exception set, the tstate->exc_type (and friends) should be NULL.
> For example, at the end of the PyInit_etree() function (called by an
> "import lxml.etree"), the tstate->exc_value contains an
> AttributeError('module' object has no attribute 'unicode').
> 
> Now, the consequence may be that all these exceptions are "implicitely
> chained" together. And there may be a subtle refcounting bug that shows
> up only if this invariant is not respected.

This explanation sounds like the right thing to do would be to clear the
exception state when a function exists cleanly but an exception was
raised and caught during its execution. So the exception state would
only stay available within the function itself. We could also try to
emulate the Py3 behaviour as outlined in PEP 3110.

http://python.org/dev/peps/pep-3110/

Opinions?

Stefan


More information about the Cython-dev mailing list