瀏覽代碼

Fix bug causing random crash during module initialization

rdb 9 年之前
父節點
當前提交
2f0bc01b68
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      dtool/src/interrogate/interfaceMakerPythonNative.cxx

+ 14 - 0
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -1212,6 +1212,10 @@ write_sub_module(ostream &out, Object *obj) {
       out << "  assert(" << class_ptr << " != NULL);\n";
     } else {
       class_ptr = "&Dtool_" + class_name;
+
+      // 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";
     }
   }
 
@@ -2692,6 +2696,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.
@@ -2938,6 +2948,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";
 
   // It's tempting to initialize the type handle here, but this causes static