no-issue: Add assertion to PyModule_GetName for understanding (GH-32236)

This commit is contained in:
Dong-hee Na 2022-04-02 09:56:30 +09:00 committed by GitHub
parent 082d3495d0
commit b183f48649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -510,8 +510,10 @@ const char *
PyModule_GetName(PyObject *m)
{
PyObject *name = PyModule_GetNameObject(m);
if (name == NULL)
if (name == NULL) {
return NULL;
}
assert(Py_REFCNT(name) >= 2);
Py_DECREF(name); /* module dict has still a reference */
return PyUnicode_AsUTF8(name);
}