[Cython] __dealloc__ called even if __cinit__ failed

Robert Bradshaw robertwb at gmail.com
Mon Oct 5 16:57:18 CEST 2015

If cinit fails half way through you still may need to do some cleanup,
hence dealloc which must be aware of this.
On Oct 5, 2015 7:12 AM, "Jeroen Demeyer" <jdemeyer at cage.ugent.be> wrote:

> Hello,
> I'm not entirely sure if this is a feature or bug...
> I noticed that, if a __cinit__ call raises an exception on an object, that
> __dealloc__ on that same object is still called.
> The problem is that __cinit__ is supposed to set up the C-level attributes
> for that object. If this somehow fails, then the object isn't in a
> consistent state yet, so it makes no sense to call __dealloc__ on it.
> Do you consider this a Cython bug or should I manually protect my code
> against this?
> Thanks,
> Jeroen.
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> https://mail.python.org/mailman/listinfo/cython-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20151005/f4a654e7/attachment.html>

More information about the cython-devel mailing list