Skip to content

Commit f10a1d8

Browse files
[3.13] Document that PyType_GetModule returns a borrowed ref (GH-145612) (GH-145732)
(cherry picked from commit 4485545 via 30bcdcd) Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent cba8d12 commit f10a1d8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Doc/c-api/type.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ Type Objects
259259
Return the module object associated with the given type when the type was
260260
created using :c:func:`PyType_FromModuleAndSpec`.
261261
262+
The returned reference is :term:`borrowed <borrowed reference>` from *type*,
263+
and will be valid as long as you hold a reference to *type*.
264+
Do not release it with :c:func:`Py_DECREF` or similar.
265+
262266
If no module is associated with the given type, sets :py:class:`TypeError`
263267
and returns ``NULL``.
264268

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,9 @@ PyType_GetFlags:PyTypeObject*:type:0:
23982398
PyType_GetName:PyObject*::+1:
23992399
PyType_GetName:PyTypeObject*:type:0:
24002400

2401+
PyType_GetModule:PyObject*::0:
2402+
PyType_GetModule:PyTypeObject*:type:0:
2403+
24012404
PyType_GetModuleByDef:PyObject*::0:
24022405
PyType_GetModuleByDef:PyTypeObject*:type:0:
24032406
PyType_GetModuleByDef:PyModuleDef*:def::

0 commit comments

Comments
 (0)