summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2022-10-08 00:37:46 (GMT)
committerGitHub <noreply@github.com>2022-10-08 00:37:46 (GMT)
commite82d977eb0b53b0d69509b7080107108e5cfc6f9 (patch)
treeabe6c2f077f76574d7f1c7c61f34ed49ac3cadbb /Doc/c-api
parent8ba9378b168ad330c158a001afca03d6c028d39b (diff)
downloadcpython-e82d977eb0b53b0d69509b7080107108e5cfc6f9.zip
cpython-e82d977eb0b53b0d69509b7080107108e5cfc6f9.tar.gz
cpython-e82d977eb0b53b0d69509b7080107108e5cfc6f9.tar.bz2
gh-91052: Add PyDict_Unwatch for unwatching a dictionary (#98055)
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/dict.rst21
1 files changed, 20 insertions, 1 deletions
diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst
index 7bebea0..e5f28b5 100644
--- a/Doc/c-api/dict.rst
+++ b/Doc/c-api/dict.rst
@@ -246,17 +246,32 @@ Dictionary Objects
of error (e.g. no more watcher IDs available), return ``-1`` and set an
exception.
+ .. versionadded:: 3.12
+
.. c:function:: int PyDict_ClearWatcher(int watcher_id)
Clear watcher identified by *watcher_id* previously returned from
:c:func:`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g.
if the given *watcher_id* was never registered.)
+ .. versionadded:: 3.12
+
.. c:function:: int PyDict_Watch(int watcher_id, PyObject *dict)
Mark dictionary *dict* as watched. The callback granted *watcher_id* by
:c:func:`PyDict_AddWatcher` will be called when *dict* is modified or
- deallocated.
+ deallocated. Return ``0`` on success or ``-1`` on error.
+
+ .. versionadded:: 3.12
+
+.. c:function:: int PyDict_Unwatch(int watcher_id, PyObject *dict)
+
+ Mark dictionary *dict* as no longer watched. The callback granted
+ *watcher_id* by :c:func:`PyDict_AddWatcher` will no longer be called when
+ *dict* is modified or deallocated. The dict must previously have been
+ watched by this watcher. Return ``0`` on success or ``-1`` on error.
+
+ .. versionadded:: 3.12
.. c:type:: PyDict_WatchEvent
@@ -264,6 +279,8 @@ Dictionary Objects
``PyDict_EVENT_MODIFIED``, ``PyDict_EVENT_DELETED``, ``PyDict_EVENT_CLONED``,
``PyDict_EVENT_CLEARED``, or ``PyDict_EVENT_DEALLOCATED``.
+ .. versionadded:: 3.12
+
.. c:type:: int (*PyDict_WatchCallback)(PyDict_WatchEvent event, PyObject *dict, PyObject *key, PyObject *new_value)
Type of a dict watcher callback function.
@@ -289,3 +306,5 @@ Dictionary Objects
If the callback returns with an exception set, it must return ``-1``; this
exception will be printed as an unraisable exception using
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
+
+ .. versionadded:: 3.12