mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #8268: Old-style classes (not just instances) now support weak
references.
This commit is contained in:
parent
26cc99da2a
commit
a57df2cf1d
5 changed files with 29 additions and 2 deletions
|
@ -123,6 +123,7 @@ alloc_error:
|
|||
op->cl_dict = dict;
|
||||
Py_XINCREF(name);
|
||||
op->cl_name = name;
|
||||
op->cl_weakreflist = NULL;
|
||||
|
||||
op->cl_getattr = class_lookup(op, getattrstr, &dummy);
|
||||
op->cl_setattr = class_lookup(op, setattrstr, &dummy);
|
||||
|
@ -188,6 +189,8 @@ static void
|
|||
class_dealloc(PyClassObject *op)
|
||||
{
|
||||
_PyObject_GC_UNTRACK(op);
|
||||
if (op->cl_weakreflist != NULL)
|
||||
PyObject_ClearWeakRefs((PyObject *) op);
|
||||
Py_DECREF(op->cl_bases);
|
||||
Py_DECREF(op->cl_dict);
|
||||
Py_XDECREF(op->cl_name);
|
||||
|
@ -454,7 +457,7 @@ PyTypeObject PyClass_Type = {
|
|||
(traverseproc)class_traverse, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
offsetof(PyClassObject, cl_weakreflist), /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue