summaryrefslogtreecommitdiff
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-03-23 03:33:13 +0000
committerTim Peters <tim.peters@gmail.com>2003-03-23 03:33:13 +0000
commit36eb4dfb819dbfe90d82e0c6b58bd360c22bcc26 (patch)
tree03aa5497be9d977f26d423c36234145668c6f4e1 /Objects/typeobject.c
parent3e40c7ff5bb54c4787290109b51394ad34ef815d (diff)
downloadcpython-git-36eb4dfb819dbfe90d82e0c6b58bd360c22bcc26.tar.gz
Refactored some of the Py_TRACE_REFS code. New private API function
_Py_AddToAllObjects() that simply inserts an object at the front of the doubly-linked list of all objects. Changed PyType_Ready() (the closest thing we've got to a choke point for type objects) to call that.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index b0297774b5..c2ed180499 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3052,6 +3052,18 @@ PyType_Ready(PyTypeObject *type)
type->tp_flags |= Py_TPFLAGS_READYING;
+#ifdef Py_TRACE_REFS
+ /* PyType_Ready is the closest thing we have to a choke point
+ * for type objects, so is the best place I can think of to try
+ * to get type objects into the doubly-linked list of all objects.
+ * Still, not all type objects go thru PyType_Ready.
+ */
+ if (type->_ob_next == NULL) {
+ assert(type->_ob_prev == NULL);
+ _Py_AddToAllObjects((PyObject *)type);
+ }
+#endif
+
/* Initialize tp_base (defaults to BaseObject unless that's us) */
base = type->tp_base;
if (base == NULL && type != &PyBaseObject_Type)