[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.139,2.140
Guido van Rossum
gvanrossum@users.sourceforge.net
Sun, 07 Apr 2002 18:38:45 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv16348/Objects
Modified Files:
typeobject.c
Log Message:
- 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.
- PyType_Ready() accidentally did not inherit tp_is_gc; now it does.
Bugfix candidate.
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.139
retrieving revision 2.140
diff -C2 -d -r2.139 -r2.140
*** typeobject.c 6 Apr 2002 01:05:00 -0000 2.139
--- typeobject.c 8 Apr 2002 01:38:42 -0000 2.140
***************
*** 2051,2064 ****
type->tp_flags |= Py_TPFLAGS_READYING;
- /* 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;
/* Initialize tp_bases */
--- 2051,2064 ----
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 = base->ob_type;
/* Initialize tp_bases */