diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-11-07 12:23:36 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-11-07 13:24:08 +0300 |
commit | a454f5fbc2c79ea1f8e9ca584d888a57f535c8f3 (patch) | |
tree | f6f4c048c1a1388d005bcf5996285ddcaedb1ba7 /contrib/python/zope.interface/py3/zope/interface/_zope_interface_coptimizations.c | |
parent | a74a901e7cd8f6eeab88e728e48c22e0de2f9a0f (diff) | |
download | ydb-a454f5fbc2c79ea1f8e9ca584d888a57f535c8f3.tar.gz |
Intermediate changes
commit_hash:8dfe46ba3b02673d0e6a35fdf824ab2c98255393
Diffstat (limited to 'contrib/python/zope.interface/py3/zope/interface/_zope_interface_coptimizations.c')
-rw-r--r-- | contrib/python/zope.interface/py3/zope/interface/_zope_interface_coptimizations.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/contrib/python/zope.interface/py3/zope/interface/_zope_interface_coptimizations.c b/contrib/python/zope.interface/py3/zope/interface/_zope_interface_coptimizations.c index 453057a4d6..45810ec617 100644 --- a/contrib/python/zope.interface/py3/zope/interface/_zope_interface_coptimizations.c +++ b/contrib/python/zope.interface/py3/zope/interface/_zope_interface_coptimizations.c @@ -49,6 +49,11 @@ #define USE_HEAP_TYPES 1 #endif +#define BASETYPE_FLAGS \ + Py_TPFLAGS_DEFAULT | \ + Py_TPFLAGS_BASETYPE | \ + Py_TPFLAGS_HAVE_GC + #if PY_VERSION_HEX >= 0x030c0000 /* Add MANAGED_WEAKREF flag for Python >= 3.12, and don't define * the '.tp_weaklistoffset' slot. @@ -57,11 +62,7 @@ * #c.PyTypeObject.tp_weaklistoffset */ #define USE_EXPLICIT_WEAKREFLIST 0 -#define BASETYPE_FLAGS \ - Py_TPFLAGS_DEFAULT | \ - Py_TPFLAGS_BASETYPE | \ - Py_TPFLAGS_MANAGED_WEAKREF | \ - Py_TPFLAGS_HAVE_GC +#define WEAKREFTYPE_FLAGS BASETYPE_FLAGS | Py_TPFLAGS_MANAGED_WEAKREF #else /* No MANAGED_WEAKREF flag for Python < 3.12, and therefore define * the '.tp_weaklistoffset' slot, and the member whose offset it holds. @@ -70,10 +71,7 @@ * #c.PyTypeObject.tp_weaklistoffset */ #define USE_EXPLICIT_WEAKREFLIST 1 -#define BASETYPE_FLAGS \ - Py_TPFLAGS_DEFAULT | \ - Py_TPFLAGS_BASETYPE | \ - Py_TPFLAGS_HAVE_GC +#define WEAKREFTYPE_FLAGS BASETYPE_FLAGS #endif /* Static strings, used to invoke PyObject_GetAttr (only in hot paths) */ @@ -276,12 +274,8 @@ static void SB_dealloc(SB* self) { PyObject_GC_UnTrack((PyObject*)self); + PyObject_ClearWeakRefs(OBJECT(self)); PyTypeObject* tp = Py_TYPE(self); -#if USE_EXPLICIT_WEAKREFLIST - if (self->weakreflist != NULL) { - PyObject_ClearWeakRefs(OBJECT(self)); - } -#endif SB_clear(self); tp->tp_free(OBJECT(self)); #if USE_HEAP_TYPES @@ -419,7 +413,7 @@ static PyTypeObject SB_type_def = { .tp_name = SB__name__, .tp_doc = SB__doc__, .tp_basicsize = sizeof(SB), - .tp_flags = BASETYPE_FLAGS, + .tp_flags = WEAKREFTYPE_FLAGS, .tp_call = (ternaryfunc)SB__call__, .tp_traverse = (traverseproc)SB_traverse, .tp_clear = (inquiry)SB_clear, @@ -450,7 +444,7 @@ static PyType_Slot SB_type_slots[] = { static PyType_Spec SB_type_spec = { .name = SB__name__, .basicsize = sizeof(SB), - .flags = BASETYPE_FLAGS, + .flags = WEAKREFTYPE_FLAGS, .slots = SB_type_slots }; @@ -569,8 +563,7 @@ CPB_clear(CPB* self) { Py_CLEAR(self->_cls); Py_CLEAR(self->_implements); - SB_clear((SB*)self); - return 0; + return SB_clear((SB*)self); } static void |