]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Document that PyType_GetModule returns a borrowed ref (GH-145612)
authorPetr Viktorin <encukou@gmail.com>
Mon, 9 Mar 2026 13:32:28 +0000 (14:32 +0100)
committerGitHub <noreply@github.com>
Mon, 9 Mar 2026 13:32:28 +0000 (14:32 +0100)
Doc/c-api/type.rst
Doc/data/refcounts.dat

index 8cadf26cee30276d93949ab534cebd805c0f7c35..c9bb5c3f09ac18631a2ded6d2dccc32c3c8be8cf 100644 (file)
@@ -274,6 +274,10 @@ Type Objects
    Return the module object associated with the given type when the type was
    created using :c:func:`PyType_FromModuleAndSpec`.
 
+   The returned reference is :term:`borrowed <borrowed reference>` from *type*,
+   and will be valid as long as you hold a reference to *type*.
+   Do not release it with :c:func:`Py_DECREF` or similar.
+
    If no module is associated with the given type, sets :py:class:`TypeError`
    and returns ``NULL``.
 
index 64399f6ab1ff26de9c6453bc672824d0c9df7c37..01b064f3e617ff5bd89e22a41c5664ba74ce3e2e 100644 (file)
@@ -2427,6 +2427,9 @@ PyType_GetFlags:PyTypeObject*:type:0:
 PyType_GetName:PyObject*::+1:
 PyType_GetName:PyTypeObject*:type:0:
 
+PyType_GetModule:PyObject*::0:
+PyType_GetModule:PyTypeObject*:type:0:
+
 PyType_GetModuleByToken:PyObject*::+1:
 PyType_GetModuleByToken:PyTypeObject*:type:0:
 PyType_GetModuleByToken:PyModuleDef*:def::