Skip to content

Commit 280cead

Browse files
committed
[3.14] Document that PyType_GetModule returns a borrowed ref (GH-145612)
(cherry picked from commit 4485545) Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent b194688 commit 280cead

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
@@ -274,6 +274,10 @@ Type Objects
274274
Return the module object associated with the given type when the type was
275275
created using :c:func:`PyType_FromModuleAndSpec`.
276276
277+
The returned reference is :term:`borrowed <borrowed reference>` from *type*,
278+
and will be valid as long as you hold a reference to *type*.
279+
Do not release it with :c:func:`Py_DECREF` or similar.
280+
277281
If no module is associated with the given type, sets :py:class:`TypeError`
278282
and returns ``NULL``.
279283

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,9 @@ PyType_GetFlags:PyTypeObject*:type:0:
24152415
PyType_GetName:PyObject*::+1:
24162416
PyType_GetName:PyTypeObject*:type:0:
24172417

2418+
PyType_GetModule:PyObject*::0:
2419+
PyType_GetModule:PyTypeObject*:type:0:
2420+
24182421
PyType_GetModuleByDef:PyObject*::0:
24192422
PyType_GetModuleByDef:PyTypeObject*:type:0:
24202423
PyType_GetModuleByDef:PyModuleDef*:def::

0 commit comments

Comments
 (0)