summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/_weakref.c.h
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2016-12-27 13:19:20 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2016-12-27 13:19:20 (GMT)
commite10ca3a0fe10d825689179e9958c70aef01f4230 (patch)
treef7dc9b56ba188d143a616062ec9e47f434aa32a3 /Modules/clinic/_weakref.c.h
parent1fee5151f72e4e141eb37e7ab0da901d1b610f45 (diff)
downloadcpython-e10ca3a0fe10d825689179e9958c70aef01f4230.zip
cpython-e10ca3a0fe10d825689179e9958c70aef01f4230.tar.gz
cpython-e10ca3a0fe10d825689179e9958c70aef01f4230.tar.bz2
Issue #28427: old keys should not remove new values from
WeakValueDictionary when collecting from another thread.
Diffstat (limited to 'Modules/clinic/_weakref.c.h')
-rw-r--r--Modules/clinic/_weakref.c.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/Modules/clinic/_weakref.c.h b/Modules/clinic/_weakref.c.h
index b83b33e..2d93679 100644
--- a/Modules/clinic/_weakref.c.h
+++ b/Modules/clinic/_weakref.c.h
@@ -28,4 +28,33 @@ _weakref_getweakrefcount(PyObject *module, PyObject *object)
exit:
return return_value;
}
-/*[clinic end generated code: output=d9086c8576d46933 input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(_weakref__remove_dead_weakref__doc__,
+"_remove_dead_weakref($module, dct, key, /)\n"
+"--\n"
+"\n"
+"Atomically remove key from dict if it points to a dead weakref.");
+
+#define _WEAKREF__REMOVE_DEAD_WEAKREF_METHODDEF \
+ {"_remove_dead_weakref", (PyCFunction)_weakref__remove_dead_weakref, METH_VARARGS, _weakref__remove_dead_weakref__doc__},
+
+static PyObject *
+_weakref__remove_dead_weakref_impl(PyObject *module, PyObject *dct,
+ PyObject *key);
+
+static PyObject *
+_weakref__remove_dead_weakref(PyObject *module, PyObject *args)
+{
+ PyObject *return_value = NULL;
+ PyObject *dct;
+ PyObject *key;
+
+ if (!PyArg_ParseTuple(args, "O!O:_remove_dead_weakref",
+ &PyDict_Type, &dct, &key))
+ goto exit;
+ return_value = _weakref__remove_dead_weakref_impl(module, dct, key);
+
+exit:
+ return return_value;
+}
+/*[clinic end generated code: output=5764cb64a6f66ffd input=a9049054013a1b77]*/