summaryrefslogtreecommitdiffstats
path: root/Modules/_functoolsmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-10-24 06:49:56 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-10-24 06:49:56 (GMT)
commit45120f272b7e1840f7c760dbad1295fa3ba68eb7 (patch)
treed78865c3c8d66585a50e6fb16579a4c6462a26f1 /Modules/_functoolsmodule.c
parenta7b83b43ff469edd3d9371164e32fe4d3e4daafa (diff)
downloadcpython-45120f272b7e1840f7c760dbad1295fa3ba68eb7.zip
cpython-45120f272b7e1840f7c760dbad1295fa3ba68eb7.tar.gz
cpython-45120f272b7e1840f7c760dbad1295fa3ba68eb7.tar.bz2
Issue #25447: The lru_cache() wrapper objects now can be copied and pickled
(by returning the original object unchanged).
Diffstat (limited to 'Modules/_functoolsmodule.c')
-rw-r--r--Modules/_functoolsmodule.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 1f98067..fadc0a9 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1047,6 +1047,12 @@ lru_cache_cache_clear(lru_cache_object *self, PyObject *unused)
Py_RETURN_NONE;
}
+static PyObject *
+lru_cache_reduce(PyObject *self, PyObject *unused)
+{
+ return PyObject_GetAttrString(self, "__qualname__");
+}
+
static int
lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg)
{
@@ -1097,6 +1103,7 @@ cache_info_type: namedtuple class with the fields:\n\
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},
{NULL}
};