-
Notifications
You must be signed in to change notification settings - Fork 223
Avoid manual cleanup of object attributes #1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
/ok to test 8a1ca77 |
|
| else: | ||
| s = <cyStream>stream | ||
| self._mr._deallocate(self._ptr, self._size, s) | ||
| self._ptr = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was something I had mentioned elsewhere, that we shouldn't be accessing object properties in a __dealloc__ code path.
Why is _ptr still being touched here?
From the Cython docs on __dealloc__:
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.
Why not just do the minimum C-API invocation required in __dealloc__ and duplicate whatever you need to from close?
Then we're not going against the documented behavior and causing a crashing knowing that we could have avoided it all along.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Try to avoid cleanup errors like this
Checklist