summaryrefslogtreecommitdiffstats
path: root/Modules
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 /Modules
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 'Modules')
-rw-r--r--Modules/_testcapimodule.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 28fb43d..173d7c2 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -5297,6 +5297,20 @@ watch_dict(PyObject *self, PyObject *args)
}
static PyObject *
+unwatch_dict(PyObject *self, PyObject *args)
+{
+ PyObject *dict;
+ int watcher_id;
+ if (!PyArg_ParseTuple(args, "iO", &watcher_id, &dict)) {
+ return NULL;
+ }
+ if (PyDict_Unwatch(watcher_id, dict)) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
get_dict_watcher_events(PyObject *self, PyObject *Py_UNUSED(args))
{
if (!g_dict_watch_events) {
@@ -5904,6 +5918,7 @@ static PyMethodDef TestMethods[] = {
{"add_dict_watcher", add_dict_watcher, METH_O, NULL},
{"clear_dict_watcher", clear_dict_watcher, METH_O, NULL},
{"watch_dict", watch_dict, METH_VARARGS, NULL},
+ {"unwatch_dict", unwatch_dict, METH_VARARGS, NULL},
{"get_dict_watcher_events", get_dict_watcher_events, METH_NOARGS, NULL},
{NULL, NULL} /* sentinel */
};