[Python-checkins] python/dist/src/Tools/bgen/bgen bgenObjectDefinition.py,1.23,1.24

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
2002年12月23日 14:33:51 -0800


Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen
In directory sc8-pr-cvs1:/tmp/cvs-serv19383
Modified Files:
	bgenObjectDefinition.py 
Log Message:
Oops, old-style types don't have a tp_free slot. Call PyObject_Free
directly in that case.
Index: bgenObjectDefinition.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenObjectDefinition.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** bgenObjectDefinition.py	19 Dec 2002 23:34:40 -0000	1.23
--- bgenObjectDefinition.py	23 Dec 2002 22:33:49 -0000	1.24
***************
*** 137,142 ****
 		if self.basetype:
 			Output("%s.tp_dealloc(self)", self.basetype)
! 		else:
 			Output("self->ob_type->tp_free((PyObject *)self);")
 		OutRbrace()
 
--- 137,145 ----
 		if self.basetype:
 			Output("%s.tp_dealloc(self)", self.basetype)
! 		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()
 
***************
*** 206,212 ****
 		
 	def outputTypeObjectInitializer(self):
! 		Output("""%s.ob_type = &PyType_Type;""", self.typename);
 		if self.basetype:
 			Output("%s.tp_base = %s;", self.typename, self.basetype)
 		Output("""Py_INCREF(&%s);""", self.typename)
 		Output("PyModule_AddObject(m, \"%s\", (PyObject *)&%s);", self.name, self.typename);
--- 209,216 ----
 		
 	def outputTypeObjectInitializer(self):
! 		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);

AltStyle によって変換されたページ (->オリジナル) /