mirror of
https://github.com/python/cpython.git
synced 2025-08-21 01:15:03 +00:00
If you created a weakref in an object's __del__ method to itself it would
segfault the interpreter during weakref clean up. Now any new weakrefs created after __del__ is run are removed silently. Fixes bug #1377858 and the weakref_in_del crasher for new-style classes. Classic classes are still affected.
This commit is contained in:
parent
601d03a5be
commit
75ba075110
5 changed files with 33 additions and 1 deletions
|
@ -57,6 +57,9 @@ clear_weakref(PyWeakReference *self)
|
|||
PyWeakref_GET_OBJECT(self));
|
||||
|
||||
if (*list == self)
|
||||
/* If 'self' is the end of the list (and thus self->wr_next == NULL)
|
||||
then the weakref list itself (and thus the value of *list) will
|
||||
end up being set to NULL. */
|
||||
*list = self->wr_next;
|
||||
self->wr_object = Py_None;
|
||||
if (self->wr_prev != NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue