Fix bug causing random crash during module initialization

This commit is contained in:
rdb 2016-04-18 14:34:50 +02:00
parent 380ff44710
commit 2f0bc01b68

View File

@ -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