mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03: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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue