gh-133166: Fix missing error emission of PyType_GetModuleByDef (GH-133240)

This commit is contained in:
neonene 2025-05-01 21:32:57 +09:00 committed by GitHub
parent 662dd29456
commit fa52f289a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 7 deletions

View file

@ -5399,7 +5399,7 @@ PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
// type_ready_mro() ensures that no heap type is
// contained in a static type MRO.
return NULL;
goto error;
}
else {
PyHeapTypeObject *ht = (PyHeapTypeObject*)type;
@ -5439,13 +5439,15 @@ PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
}
END_TYPE_LOCK();
if (res == NULL) {
PyErr_Format(
PyExc_TypeError,
"PyType_GetModuleByDef: No superclass of '%s' has the given module",
type->tp_name);
if (res != NULL) {
return res;
}
return res;
error:
PyErr_Format(
PyExc_TypeError,
"PyType_GetModuleByDef: No superclass of '%s' has the given module",
type->tp_name);
return NULL;
}