diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2016-12-27 14:23:43 +0100 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2016-12-27 14:23:43 +0100 |
commit | d741ed492f17609109432f1bccac0c019a05471b (patch) | |
tree | 5b4425dfb7360f55993971d1b2fc9ebe7d1f00fa /Modules/clinic | |
parent | 34d0ac8027e23609e24588735b37b8d5a55f7223 (diff) | |
parent | e10ca3a0fe10d825689179e9958c70aef01f4230 (diff) | |
download | cpython-git-d741ed492f17609109432f1bccac0c019a05471b.tar.gz |
Issue #28427: old keys should not remove new values from
WeakValueDictionary when collecting from another thread.
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/_weakref.c.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/Modules/clinic/_weakref.c.h b/Modules/clinic/_weakref.c.h index c192e72193..ab84c304d9 100644 --- a/Modules/clinic/_weakref.c.h +++ b/Modules/clinic/_weakref.c.h @@ -29,4 +29,34 @@ _weakref_getweakrefcount(PyObject *module, PyObject *object) exit: return return_value; } -/*[clinic end generated code: output=e1ad587147323e19 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=e860dd818a44bc9b input=a9049054013a1b77]*/ |