]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] Document that PyType_GetModule returns a borrowed ref (GH-145612) (GH-145732)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 10 Mar 2026 09:32:06 +0000 (10:32 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Mar 2026 09:32:06 +0000 (10:32 +0100)
(cherry picked from commit 44855458a423569eaea3df53fd5a0c0032da932d via 30bcdcd379445b942e1278244bbce805dc32b5a2)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Doc/c-api/type.rst
Doc/data/refcounts.dat

index 84a5b0fc3c0c77ea055a5d5ddf748b09f33bae7d..1d94718b2d2313cc38b4471810d2d72f52f860a4 100644 (file)
@@ -259,6 +259,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 67f551cf6de4428e7845b9bbcfba28c233aaa7af..9e0ce81627f255800dc8f34393ce1b338a8ef481 100644 (file)
@@ -2398,6 +2398,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::