cpython: c9b7272e2553 (original) (raw)

Mercurial > cpython

changeset 104271:c9b7272e2553 3.5

ensure gc tracking is off when invoking weakref callbacks (closes #26617) [#26617]

Benjamin Peterson benjamin@python.org
date Tue, 04 Oct 2016 00:00:02 -0700
parents b24d0f274623
children 520cb70ecb90 b674fd340a23
files Lib/test/test_weakref.py Misc/NEWS Objects/typeobject.c
diffstat 3 files changed, 24 insertions(+), 13 deletions(-)[+] [-] Lib/test/test_weakref.py 8 Misc/NEWS 2 Objects/typeobject.c 27

line wrap: on

line diff

--- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -845,6 +845,14 @@ class ReferencesTestCase(TestBase): with self.assertRaises(AttributeError): ref1.callback = lambda ref: None

+ class SubclassableWeakrefTestCase(TestBase):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Release date: TBA Core and Builtins ----------------- +- Issue #26617: Fix crash when GC runs during weakref callbacks. +

--- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1123,11 +1123,6 @@ subtype_dealloc(PyObject *self) Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; -- tstate->trash_delete_nesting;

/* Find the nearest base with a different tp_dealloc */ base = type; @@ -1138,30 +1133,36 @@ subtype_dealloc(PyObject *self) has_finalizer = type->tp_finalize || type->tp_del;

-

+

if (type->tp_del) {