mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
bpo-36650: Fix handling of empty keyword args in C version of lru_cache. (GH-12881)
This commit is contained in:
parent
9d062d690b
commit
14adbd4598
3 changed files with 21 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue