@@ -359,7 +359,6 @@ implementation must name its arguments exactly *visit* and *arg*:
359359 } \
360360 }
361361
362- .. _duringgc-functions :
363362
364363 Traversal-safe functions
365364^^^^^^^^^^^^^^^^^^^^^^^^
@@ -376,23 +375,33 @@ The following functions and macros are safe to use in a
376375 :c:func: `PyType_HasFeature `
377376* :samp: `Py{ <type> } _Check ` and :samp: `Py{ <type> } _CheckExact ` -- for example,
378377 :c:func: `PyTuple_Check `
378+ * :ref: `duringgc-functions `
379+
380+ .. _duringgc-functions :
381+
382+ "DuringGC" functions
383+ ^^^^^^^^^^^^^^^^^^^^
379384
380385The following functions should *only * used in a
381386:c:member: `~PyTypeObject.tp_traverse ` handler; calling them in other
382- contexts may have unintended consequences:
387+ contexts may have unintended consequences.
388+
389+ These functions act like their counterparts without the ``_DuringGC `` suffix,
390+ but they are guaranteed to not have side effects, they do not set an exception
391+ on failure, and they return/set :term: `borrowed references <borrowed reference> `
392+ as detailed in the individual documentation..
393+
394+ Note that these functions may fail (return ``NULL `` or ``-1 ``),
395+ but as they do not set an exception, no error information is available.
396+ In some cases, failure is not distinguishable from a successful ``NULL`` result.
383397
384398.. c:function:: void *PyObject_GetTypeData_DuringGC(PyObject *o, PyTypeObject *cls)
385399 void *PyObject_GetItemData_DuringGC(PyObject *o)
386400 void *PyType_GetModuleState_DuringGC(PyTypeObject *type)
387401 void *PyModule_GetState_DuringGC(PyObject *module)
388402 int PyModule_GetToken_DuringGC(PyObject *module, void* * result)
389403
390- These functions act like their counterparts without the ``_DuringGC`` suffix,
391- but they are guaranteed to not have side effects, and they do not
392- set an exception on failure.
393-
394- Note that these functions may fail (return ``NULL `` or -1).
395- Only creating and setting the exception is suppressed.
404+ See :ref:`duringgc-functions` for common information.
396405
397406 .. versionadded:: next
398407
@@ -407,29 +416,23 @@ contexts may have unintended consequences:
407416
408417.. c:function:: int PyType_GetBaseByToken_DuringGC(PyTypeObject *type, void *tp_token, PyTypeObject **result)
409418
410- Acts like :c:func: `PyType_GetBaseByToken `,
411- but is guaranteed to not have side effects, does not
412- set an exception on failure, and sets *\* result * to
413- a :term: `borrowed reference ` rather than a strong one.
419+ See :ref: `duringgc-functions ` for common information.
420+
421+ Sets *\* result * to a :term: `borrowed reference ` rather than a strong one.
414422 The reference is valid for the duration
415423 of the :c:member: `!tp_traverse ` handler call.
416424
417- Note that this function may fail (return -1).
418- Only creating and setting the exception is suppressed.
419-
420425 .. versionadded :: next
421426
427+ .. seealso :: :c:func:`PyType_GetBaseByToken`
428+
422429.. c :function :: PyObject* PyType_GetModule_DuringGC (PyTypeObject *type)
423430 PyObject * PyType_GetModuleByToken_DuringGC(PyTypeObject *type, const void *mod_token)
424431
425- These functions act like their counterparts without the ``_DuringGC `` suffix,
426- but they are guaranteed to not have side effects, they never set an
427- exception on failure, and they return a :term: `borrowed reference `.
428- The returned reference is valid for the duration
429- of the :c:member: `!tp_traverse ` handler call.
432+ See :ref: `duringgc-functions ` for common information.
430433
431- Note that these functions may fail (return `` NULL ``).
432- Only creating and setting the exception is suppressed .
434+ These functions return a :term: ` borrowed reference `, which is
435+ valid for the duration of the :c:member: ` !tp_traverse ` handler call .
433436
434437 .. versionadded :: next
435438
0 commit comments