]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] Document that PyType_GetModule returns a borrowed ref (GH-145612) (GH-145682)
authorPetr Viktorin <encukou@gmail.com>
Tue, 10 Mar 2026 09:06:08 +0000 (10:06 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Mar 2026 09:06:08 +0000 (10:06 +0100)
(cherry picked from commit 44855458a423569eaea3df53fd5a0c0032da932d)

Doc/c-api/type.rst
Doc/data/refcounts.dat

index 2f2060d058225152758cea1d7300fe6531ab8a3a..7fe810f585fa35e95234185f9632b1afeeec92cb 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 1cc1b44a5b8e3a2a82bc7c5dab1f596d8216358b..48b800fdf9a5336aa2078dac80160d3b9db7e339 100644 (file)
@@ -2415,6 +2415,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_GetModuleByDef:PyObject*::0:
 PyType_GetModuleByDef:PyTypeObject*:type:0:
 PyType_GetModuleByDef:PyModuleDef*:def::