From 970b03e69945ebf624ba0a80a3062c326ad4f99e Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Thu, 1 Dec 2022 07:36:05 -0800 Subject: [PATCH 1/2] gh-99767: update PyTypeObject docs for type watchers --- Doc/c-api/typeobj.rst | 11 +++++++++++ Doc/includes/typestruct.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 8f8869ec668a8d..81f8749dc7c597 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -147,6 +147,8 @@ Quick Reference +------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+ | :c:member:`~PyTypeObject.tp_vectorcall` | :c:type:`vectorcallfunc` | | | | | | +------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+ + | :c:member:`~PyTypeObject.tp_watched` | char | | | | | | + +------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+ .. [#slots] @@ -2090,6 +2092,15 @@ and :c:type:`PyType_Type` effectively act as defaults.) .. versionadded:: 3.9 (the field exists since 3.8 but it's only used since 3.9) +.. c:member:: char PyTypeObject.tp_watched + + Bitset marking which of the (up to eight) registered :c:func:`type + watchers` are watching this type (via + :c:func:`PyType_Watch`.) + + .. versionadded:: 3.12 + + .. _static-types: Static Types diff --git a/Doc/includes/typestruct.h b/Doc/includes/typestruct.h index 02f8ccfe4438a5..f0ad1e47cb0d86 100644 --- a/Doc/includes/typestruct.h +++ b/Doc/includes/typestruct.h @@ -80,4 +80,7 @@ typedef struct _typeobject { destructor tp_finalize; vectorcallfunc tp_vectorcall; + + /* bitset of which type-watchers care about this type */ + char tp_watched; } PyTypeObject; From b1a1157fec2c23840b3117f385104da9273501bd Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 14 Dec 2022 11:23:36 -0800 Subject: [PATCH 2/2] Remove description of tp_watched, just say its internal --- Doc/c-api/typeobj.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 81f8749dc7c597..c7b318b21853e5 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -2094,9 +2094,7 @@ and :c:type:`PyType_Type` effectively act as defaults.) .. c:member:: char PyTypeObject.tp_watched - Bitset marking which of the (up to eight) registered :c:func:`type - watchers` are watching this type (via - :c:func:`PyType_Watch`.) + Internal. Do not use. .. versionadded:: 3.12