Merge 3.6 (issue #28653)

This commit is contained in:
Yury Selivanov 2016-11-09 18:56:26 -05:00
commit 0a66a1cdd6
3 changed files with 27 additions and 2 deletions

View file

@ -793,8 +793,10 @@ infinite_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwd
if (!key)
return NULL;
hash = PyObject_Hash(key);
if (hash == -1)
if (hash == -1) {
Py_DECREF(key);
return NULL;
}
result = _PyDict_GetItem_KnownHash(self->cache, key, hash);
if (result) {
Py_INCREF(result);
@ -849,8 +851,10 @@ bounded_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds
if (!key)
return NULL;
hash = PyObject_Hash(key);
if (hash == -1)
if (hash == -1) {
Py_DECREF(key);
return NULL;
}
link = (lru_list_elem *)_PyDict_GetItem_KnownHash(self->cache, key, hash);
if (link) {
lru_cache_extricate_link(link);