diff Objects/typeobject.c @ 22872:d462c790cc5b 2.2

- A type can now inherit its metatype from its base type. Previously, when PyType_Ready() was called, if ob_type was found to be NULL, it was always set to &PyType_Type; now it is set to base->ob_type, where base is tp_base, defaulting to &PyObject_Type.
author Guido van Rossum <guido@python.org>
date Mon, 08 Apr 2002 01:39:56 +0000
parents 416db8d96216
children 737f4458e5de
line wrap: on
line diff
--- a/Objects/typeobject.c	Sun Apr 07 21:59:38 2002 +0000
+++ b/Objects/typeobject.c	Mon Apr 08 01:39:56 2002 +0000
@@ -2002,16 +2002,16 @@
 
 	type->tp_flags |= Py_TPFLAGS_READYING;
 
+	/* Initialize tp_base (defaults to BaseObject unless that's us) */
+	base = type->tp_base;
+	if (base == NULL && type != &PyBaseObject_Type)
+		base = type->tp_base = &PyBaseObject_Type;
+
 	/* Initialize ob_type if NULL.  This means extensions that want to be
 	   compilable separately on Windows can call PyType_Ready() instead of
 	   initializing the ob_type field of their type objects. */
 	if (type->ob_type == NULL)
-		type->ob_type = &PyType_Type;
-
-	/* Initialize tp_base (defaults to BaseObject unless that's us) */
-	base = type->tp_base;
-	if (base == NULL && type != &PyBaseObject_Type)
-		base = type->tp_base = &PyBaseObject_Type;
+		type->ob_type = base->ob_type;
 
 	/* Initialize tp_bases */
 	bases = type->tp_bases;