summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-12-23 22:33:49 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-12-23 22:33:49 (GMT)
commit15721c5c45496a2a9114eeddcce98c474a78b4f8 (patch)
tree3985372b2c19711b75cc5b866a796b7f5945b864
parent29fb9c7e076232096fe2c81647592660ca498228 (diff)
downloadcpython-15721c5c45496a2a9114eeddcce98c474a78b4f8.zip
cpython-15721c5c45496a2a9114eeddcce98c474a78b4f8.tar.gz
cpython-15721c5c45496a2a9114eeddcce98c474a78b4f8.tar.bz2
Oops, old-style types don't have a tp_free slot. Call PyObject_Free
directly in that case.
-rw-r--r--Tools/bgen/bgen/bgenObjectDefinition.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Tools/bgen/bgen/bgenObjectDefinition.py b/Tools/bgen/bgen/bgenObjectDefinition.py
index fd60d61..986b407 100644
--- a/Tools/bgen/bgen/bgenObjectDefinition.py
+++ b/Tools/bgen/bgen/bgenObjectDefinition.py
@@ -136,8 +136,11 @@ class ObjectDefinition(GeneratorGroup):
self.outputCleanupStructMembers()
if self.basetype:
Output("%s.tp_dealloc(self)", self.basetype)
- else:
+ elif hasattr(self, 'output_tp_free'):
+ # This is a new-style object with tp_free slot
Output("self->ob_type->tp_free((PyObject *)self);")
+ else:
+ Output("PyObject_Free((PyObject *)self);")
OutRbrace()
def outputCleanupStructMembers(self):
@@ -205,9 +208,10 @@ class ObjectDefinition(GeneratorGroup):
Output("};")
def outputTypeObjectInitializer(self):
- Output("""%s.ob_type = &PyType_Type;""", self.typename);
+ Output("""%s.ob_type = &PyType_Type;""", self.typename)
if self.basetype:
Output("%s.tp_base = %s;", self.typename, self.basetype)
+ Output("if (PyType_Ready(&%s) < 0) return;", self.typename)
Output("""Py_INCREF(&%s);""", self.typename)
Output("PyModule_AddObject(m, \"%s\", (PyObject *)&%s);", self.name, self.typename);
Output("/* Backward-compatible name */")