summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapi
diff options
context:
space:
mode:
authorItamar Ostricher <itamarost@gmail.com>2022-12-04 12:38:21 (GMT)
committerGitHub <noreply@github.com>2022-12-04 12:38:21 (GMT)
commit1012dc1b4367e05b92d67ea6925a39d50dce31b7 (patch)
tree2c979fea8af8e6a999d6f80e73cf148bc0cf60c8 /Modules/_testcapi
parent76f43fc09af29401cc0cec7710b03e4dbf8a4578 (diff)
downloadcpython-1012dc1b4367e05b92d67ea6925a39d50dce31b7.zip
cpython-1012dc1b4367e05b92d67ea6925a39d50dce31b7.tar.gz
cpython-1012dc1b4367e05b92d67ea6925a39d50dce31b7.tar.bz2
GH-91054: Reset static events counts in code watchers tests (#99978)
Diffstat (limited to 'Modules/_testcapi')
-rw-r--r--Modules/_testcapi/watchers.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_testcapi/watchers.c b/Modules/_testcapi/watchers.c
index f0e51fd..1d91c20 100644
--- a/Modules/_testcapi/watchers.c
+++ b/Modules/_testcapi/watchers.c
@@ -325,9 +325,13 @@ add_code_watcher(PyObject *self, PyObject *which_watcher)
long which_l = PyLong_AsLong(which_watcher);
if (which_l == 0) {
watcher_id = PyCode_AddWatcher(first_code_object_callback);
+ num_code_object_created_events[0] = 0;
+ num_code_object_destroyed_events[0] = 0;
}
else if (which_l == 1) {
watcher_id = PyCode_AddWatcher(second_code_object_callback);
+ num_code_object_created_events[1] = 0;
+ num_code_object_destroyed_events[1] = 0;
}
else {
return NULL;
@@ -346,6 +350,11 @@ clear_code_watcher(PyObject *self, PyObject *watcher_id)
if (PyCode_ClearWatcher(watcher_id_l) < 0) {
return NULL;
}
+ // reset static events counters
+ if (watcher_id_l >= 0 && watcher_id_l < NUM_CODE_WATCHERS) {
+ num_code_object_created_events[watcher_id_l] = 0;
+ num_code_object_destroyed_events[watcher_id_l] = 0;
+ }
Py_RETURN_NONE;
}