]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
no-issue: Add assertion to PyModule_GetName for understanding (GH-32236)
authorDong-hee Na <donghee.na@python.org>
Sat, 2 Apr 2022 00:56:30 +0000 (09:56 +0900)
committerGitHub <noreply@github.com>
Sat, 2 Apr 2022 00:56:30 +0000 (09:56 +0900)
Objects/moduleobject.c

index 738b262288bcd4e468de28a1b597f9ad93152437..dba20a0b36463d37f2a980429fb7d874a824ef6e 100644 (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);
 }