Skip to content

Commit b183f48

Browse files
authored
no-issue: Add assertion to PyModule_GetName for understanding (GH-32236)
1 parent 082d349 commit b183f48

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Objects/moduleobject.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,10 @@ const char *
510510
PyModule_GetName(PyObject *m)
511511
{
512512
PyObject *name = PyModule_GetNameObject(m);
513-
if (name == NULL)
513+
if (name == NULL) {
514514
return NULL;
515+
}
516+
assert(Py_REFCNT(name) >= 2);
515517
Py_DECREF(name); /* module dict has still a reference */
516518
return PyUnicode_AsUTF8(name);
517519
}

0 commit comments

Comments
 (0)