summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-01-31 23:03:38 (GMT)
committerGitHub <noreply@github.com>2019-01-31 23:03:38 (GMT)
commitffdf1c30ab6940a5efe6f33e61678021d9fd14b6 (patch)
tree138f5c1c224f1c9fe01da04f2c60ce8c9c95ab36 /Modules
parentdcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c (diff)
downloadcpython-ffdf1c30ab6940a5efe6f33e61678021d9fd14b6.zip
cpython-ffdf1c30ab6940a5efe6f33e61678021d9fd14b6.tar.gz
cpython-ffdf1c30ab6940a5efe6f33e61678021d9fd14b6.tar.bz2
Consistently move the misses update to just before the user function call (GH-11715)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_functoolsmodule.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 1412102..d72aaff 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -796,10 +796,12 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)
static PyObject *
uncached_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds)
{
- PyObject *result = PyObject_Call(self->func, args, kwds);
+ PyObject *result;
+
+ self->misses++;
+ result = PyObject_Call(self->func, args, kwds);
if (!result)
return NULL;
- self->misses++;
return result;
}
@@ -827,6 +829,7 @@ infinite_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwd
Py_DECREF(key);
return NULL;
}
+ self->misses++;
result = PyObject_Call(self->func, args, kwds);
if (!result) {
Py_DECREF(key);
@@ -838,7 +841,6 @@ infinite_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwd
return NULL;
}
Py_DECREF(key);
- self->misses++;
return result;
}