summaryrefslogtreecommitdiffstats
path: root/Modules/_threadmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r--Modules/_threadmodule.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 77baba4..56ed8a2 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -816,10 +816,14 @@ local_clear(localobject *self)
for(tstate = PyInterpreterState_ThreadHead(tstate->interp);
tstate;
tstate = PyThreadState_Next(tstate))
- if (tstate->dict && PyDict_GetItem(tstate->dict, self->key)) {
- if (PyDict_DelItem(tstate->dict, self->key)) {
+ if (tstate->dict) {
+ PyObject *v = _PyDict_Pop(tstate->dict, self->key, Py_None);
+ if (v == NULL) {
PyErr_Clear();
}
+ else {
+ Py_DECREF(v);
+ }
}
}
return 0;