Skip to content

Commit 140731f

Browse files
authored
Document that PyType_GetModuleByDef returns a borrowed reference (GH-135666)
1 parent 725da50 commit 140731f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Doc/c-api/type.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ Type Objects
282282
and other places where a method's defining class cannot be passed using the
283283
:c:type:`PyCMethod` calling convention.
284284
285+
The returned reference is :term:`borrowed <borrowed reference>` from *type*,
286+
and will be valid as long as you hold a reference to *type*.
287+
Do not release it with :c:func:`Py_DECREF` or similar.
288+
285289
.. versionadded:: 3.11
286290
287291
.. c:function:: int PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)

Doc/data/refcounts.dat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,10 @@ PyType_GetFlags:PyTypeObject*:type:0:
23852385
PyType_GetName:PyObject*::+1:
23862386
PyType_GetName:PyTypeObject*:type:0:
23872387

2388+
PyType_GetModuleByDef:PyObject*::0:
2389+
PyType_GetModuleByDef:PyTypeObject*:type:0:
2390+
PyType_GetModuleByDef:PyModuleDef*:def::
2391+
23882392
PyType_GetQualName:PyObject*::+1:
23892393
PyType_GetQualName:PyTypeObject*:type:0:
23902394

0 commit comments

Comments
 (0)