From d2bd4181e0d2eae10b467b70870d1cbd0b8035bc Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 6 Nov 2019 10:49:53 +0100 Subject: [PATCH] interrogate: set tp_base to DTOOL_SUPER_BASE and tp_basicsize to 0 The tp_basicsize field, as well as a few others, seem to be inherited from whatever is set in tp_base. In absence of a tp_base, Python will set it to PyBaseObject_Type, which is not at all correct for Panda types. --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5e8f76e9a5..2a4dd7fa68 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2874,7 +2874,7 @@ write_module_class(ostream &out, Object *obj) { // const char *tp_name; out << " \"" << _def->module_name << "." << export_class_name << "\",\n"; // Py_ssize_t tp_basicsize; - out << " sizeof(Dtool_PyInstDef),\n"; + out << " 0, // tp_basicsize\n"; // inherited from tp_base // Py_ssize_t tp_itemsize; out << " 0, // tp_itemsize\n"; @@ -3137,9 +3137,8 @@ write_module_class(ostream &out, Object *obj) { } out << " Dtool_" << ClassName << "._PyType.tp_bases = PyTuple_Pack(" << bases.size() << baseargs << ");\n"; - } else { - out << " Dtool_" << ClassName << "._PyType.tp_base = (PyTypeObject *)Dtool_GetSuperBase();\n"; } + out << " Dtool_" << ClassName << "._PyType.tp_base = (PyTypeObject *)Dtool_GetSuperBase();\n"; int num_nested = obj->_itype.number_of_nested_types(); int num_dict_items = 1;