silx-kit / silx

silx toolkit
http://www.silx.org/doc/silx/latest/
MIT License
129 stars 73 forks source link

silx.io.specfile: Fixed `SpecFile` deallocation issue #4129

Closed t20100 closed 3 months ago

t20100 commented 4 months ago

Checklist:


Replaces the use of __dealloc__ in SpecFile with __del__ since the former should not call methods and the later is now supported (it was not with Python 2):

https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#finalization-methods-dealloc-and-del

You need to be careful what you do in a __dealloc__() method. By the time your __dealloc__() method is called, the object may already have been partially destroyed and may not be in a valid state as far as Python is concerned, so you should avoid invoking any Python operations which might touch the object. In particular, don’t call any other methods of the object or do anything which might cause the object to be resurrected. It’s best if you stick to just deallocating C data.

closes #4128

stanislavlevin commented 4 months ago

I confirm that I can't see the reported problem with this fix. Thank you!

t20100 commented 4 months ago

Thanks for testing!