Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check return value of _PyType_GetModuleName
  • Loading branch information
furkanonder committed Feb 24, 2024
commit 810b5ca9228a7cde82571a32a20503949ab9fbd5
22 changes: 16 additions & 6 deletions Modules/_functoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ partial_repr(partialobject *pto)
PyObject *result = NULL;
PyObject *arglist;
PyObject *mod;
PyObject *name;
Py_ssize_t i, n;
PyObject *key, *value;
int status;
Expand Down Expand Up @@ -402,17 +403,26 @@ partial_repr(partialobject *pto)
}

mod = _PyType_GetModuleName(Py_TYPE(pto));

if (mod == NULL) {
result = PyUnicode_FromFormat("%S(%R%U)",
PyType_GetQualName(Py_TYPE(pto)),
pto->fn, arglist);
name = PyType_GetQualName(Py_TYPE(pto));
if (name == NULL) {
return NULL;
}
result = PyUnicode_FromFormat("%S(%R%U)", name, pto->fn, arglist);
}
else {
result = PyUnicode_FromFormat("%U.%S(%R%U)",
mod, PyType_GetQualName(Py_TYPE(pto)),
pto->fn, arglist);
name = PyType_GetQualName(Py_TYPE(pto));
if (name == NULL) {
Py_DECREF(mod);
return NULL;
}
result = PyUnicode_FromFormat("%U.%S(%R%U)", mod, name, pto->fn,
arglist);
Py_DECREF(mod);
}

Py_DECREF(name);
Py_DECREF(arglist);

done:
Expand Down