summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-04-08 01:38:42 (GMT)
committerGuido van Rossum <guido@python.org>2002-04-08 01:38:42 (GMT)
commit0986d8250f7ae4019c3e5b5c934dc0fd55f2b8de (patch)
tree162b8dd072e2073e3b77b149f532e7d93877008b
parentd1a3c8117d858c96feef7a1431448cbbcb08a8c3 (diff)
downloadcpython-0986d8250f7ae4019c3e5b5c934dc0fd55f2b8de.zip
cpython-0986d8250f7ae4019c3e5b5c934dc0fd55f2b8de.tar.gz
cpython-0986d8250f7ae4019c3e5b5c934dc0fd55f2b8de.tar.bz2
- 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.
-rw-r--r--Misc/NEWS7
-rw-r--r--Objects/typeobject.c12
2 files changed, 13 insertions, 6 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 4923dce..bb5792c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -123,6 +123,13 @@ Build
C API
+- 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.
+
- Objects allocated using the new PyMalloc_New and PyMalloc_NewVar
functions will be allocated using pymalloc if it is enabled. These
objects should be deallocated using PyMalloc_Del. The PyObject_{New,
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 51ed430..fff95b4 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2050,17 +2050,17 @@ PyType_Ready(PyTypeObject *type)
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 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 */
bases = type->tp_bases;
if (bases == NULL) {