summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-04-20 17:20:44 (GMT)
committerGitHub <noreply@github.com>2019-04-20 17:20:44 (GMT)
commit14adbd45980f705cb6554ca17b8a66b56e105296 (patch)
tree07074a6677cbf71830c1cfd3c3ebdf6652c8685b /Lib
parent9d062d690b768252204992fc6ab7c3873a87442d (diff)
downloadcpython-14adbd45980f705cb6554ca17b8a66b56e105296.zip
cpython-14adbd45980f705cb6554ca17b8a66b56e105296.tar.gz
cpython-14adbd45980f705cb6554ca17b8a66b56e105296.tar.bz2
bpo-36650: Fix handling of empty keyword args in C version of lru_cache. (GH-12881)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_functools.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 4b2b9ab..9890840 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1271,6 +1271,20 @@ class TestLRU:
self.assertEqual(f(20), '.20.')
self.assertEqual(f.cache_info().currsize, 10)
+ def test_lru_bug_36650(self):
+ # C version of lru_cache was treating a call with an empty **kwargs
+ # dictionary as being distinct from a call with no keywords at all.
+ # This did not result in an incorrect answer, but it did trigger
+ # an unexpected cache miss.
+
+ @self.module.lru_cache()
+ def f(x):
+ pass
+
+ f(0)
+ f(0, **{})
+ self.assertEqual(f.cache_info().hits, 1)
+
def test_lru_hash_only_once(self):
# To protect against weird reentrancy bugs and to improve
# efficiency when faced with slow __hash__ methods, the