summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-04-20 10:50:32 -0700
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2019-04-20 07:50:32 -1000
commit8b30ee843528d0f0e2bfc3307d86658915579c21 (patch)
treefc018f0ee982e3398d49ebedaa41720d6a750f06 /Modules
parentd29b3dd9227cfc4a23f77e99d62e20e063272de1 (diff)
downloadcpython-git-8b30ee843528d0f0e2bfc3307d86658915579c21.tar.gz
bpo-36650: Fix handling of empty keyword args in C version of lru_cache. (GH-12881) (GH-12888)
(cherry picked from commit 14adbd45980f705cb6554ca17b8a66b56e105296) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_functoolsmodule.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index c6a92ed169..c0578554a6 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -750,8 +750,10 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)
PyObject *key, *keyword, *value;
Py_ssize_t key_size, pos, key_pos, kwds_size;
+ kwds_size = kwds ? PyDict_GET_SIZE(kwds) : 0;
+
/* short path, key will match args anyway, which is a tuple */
- if (!typed && !kwds) {
+ if (!typed && !kwds_size) {
if (PyTuple_GET_SIZE(args) == 1) {
key = PyTuple_GET_ITEM(args, 0);
if (PyUnicode_CheckExact(key) || PyLong_CheckExact(key)) {
@@ -765,9 +767,6 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)
return args;
}
- kwds_size = kwds ? PyDict_GET_SIZE(kwds) : 0;
- assert(kwds_size >= 0);
-
key_size = PyTuple_GET_SIZE(args);
if (kwds_size)
key_size += kwds_size * 2 + 1;