bpo-36650: Fix handling of empty keyword args in C version of lru_cac… · python/cpython@14adbd4

@@ -750,8 +750,10 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)

750750

PyObject *key, *keyword, *value;

751751

Py_ssize_t key_size, pos, key_pos, kwds_size;

752752753+

kwds_size = kwds ? PyDict_GET_SIZE(kwds) : 0;

754+753755

/* short path, key will match args anyway, which is a tuple */

754-

if (!typed && !kwds) {

756+

if (!typed && !kwds_size) {

755757

if (PyTuple_GET_SIZE(args) == 1) {

756758

key = PyTuple_GET_ITEM(args, 0);

757759

if (PyUnicode_CheckExact(key) || PyLong_CheckExact(key)) {

@@ -765,9 +767,6 @@ lru_cache_make_key(PyObject *args, PyObject *kwds, int typed)

765767

return args;

766768

}

767769768-

kwds_size = kwds ? PyDict_GET_SIZE(kwds) : 0;

769-

assert(kwds_size >= 0);

770-771770

key_size = PyTuple_GET_SIZE(args);

772771

if (kwds_size)

773772

key_size += kwds_size * 2 + 1;