From 0821bec2d0f9664b9a84f9789f37ad918e648e26 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 22 Jun 2016 15:04:00 +0200 Subject: [PATCH] Backport 2f0bc01 to 1.9: Fix bug causing random crash during module initialization --- .../src/interrogate/interfaceMakerPythonNative.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 1091132312..db1825c079 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1198,6 +1198,10 @@ write_sub_module(ostream &out, Object *obj) { if (!isExportThisRun(wrapped_itype._cpptype)) { _external_imports.insert(wrapped_itype._cpptype); + } else { + // If this is a typedef to a class defined in the same module, make sure + // that the class is initialized before we try to define the typedef. + out << " Dtool_PyModuleClassInit_" << class_name << "(module);\n"; } } @@ -2595,6 +2599,12 @@ write_module_class(ostream &out, Object *obj) { out << "#if PY_VERSION_HEX >= 0x02050000\n"; write_function_slot(out, 2, slots, "nb_index"); out << "#endif\n"; + + out << "#if PY_VERSION_HEX >= 0x03050000\n"; + write_function_slot(out, 2, slots, "nb_matrix_multiply"); + write_function_slot(out, 2, slots, "nb_inplace_matrix_multiply"); + out << "#endif\n"; + out << "};\n\n"; // NB: it's tempting not to write this table when a class doesn't have them. @@ -2843,6 +2853,10 @@ write_module_class(ostream &out, Object *obj) { out << "#if PY_VERSION_HEX >= 0x02060000\n"; out << " 0, // tp_version_tag\n"; out << "#endif\n"; + // destructor tp_finalize + out << "#if PY_VERSION_HEX >= 0x03040000\n"; + out << " 0, // tp_finalize\n"; + out << "#endif\n"; out << " },\n"; out << " Dtool_UpcastInterface_" << ClassName << ",\n"; out << " Dtool_DowncastInterface_" << ClassName << ",\n";