diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-28 21:58:07 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-28 21:58:07 (GMT) |
commit | e4d65e3aab980cd8c2347d71bc6e26c19227953b (patch) | |
tree | d6346ffe9e07b111427262150f942d941b18830a /Modules/_functoolsmodule.c | |
parent | 762d5ea8753e2c137eb7affa9fcb51db1cecd1aa (diff) | |
download | cpython-e4d65e3aab980cd8c2347d71bc6e26c19227953b.zip cpython-e4d65e3aab980cd8c2347d71bc6e26c19227953b.tar.gz cpython-e4d65e3aab980cd8c2347d71bc6e26c19227953b.tar.bz2 |
Issue #25447: Copying the lru_cache() wrapper object now always works,
independedly from the type of the wrapped object (by returning the original
object unchanged).
Diffstat (limited to 'Modules/_functoolsmodule.c')
-rw-r--r-- | Modules/_functoolsmodule.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index fadc0a9..035d3d9 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1053,6 +1053,20 @@ lru_cache_reduce(PyObject *self, PyObject *unused) return PyObject_GetAttrString(self, "__qualname__"); } +static PyObject * +lru_cache_copy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + +static PyObject * +lru_cache_deepcopy(PyObject *self, PyObject *unused) +{ + Py_INCREF(self); + return self; +} + static int lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg) { @@ -1104,6 +1118,8 @@ static PyMethodDef lru_cache_methods[] = { {"cache_info", (PyCFunction)lru_cache_cache_info, METH_NOARGS}, {"cache_clear", (PyCFunction)lru_cache_cache_clear, METH_NOARGS}, {"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS}, + {"__copy__", (PyCFunction)lru_cache_copy, METH_VARARGS}, + {"__deepcopy__", (PyCFunction)lru_cache_deepcopy, METH_VARARGS}, {NULL} }; |