mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #28653: Fix a refleak in functools.lru_cache.
This commit is contained in:
parent
28f42fd4f8
commit
46a02db90b
3 changed files with 27 additions and 2 deletions
|
|
@ -1162,6 +1162,25 @@ class TestLRU:
|
|||
self.assertEqual(misses, 4)
|
||||
self.assertEqual(currsize, 2)
|
||||
|
||||
def test_lru_type_error(self):
|
||||
# Regression test for issue #28653.
|
||||
# lru_cache was leaking when one of the arguments
|
||||
# wasn't cacheable.
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
def infinite_cache(o):
|
||||
pass
|
||||
|
||||
@functools.lru_cache(maxsize=10)
|
||||
def limited_cache(o):
|
||||
pass
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
infinite_cache([])
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
limited_cache([])
|
||||
|
||||
def test_lru_with_maxsize_none(self):
|
||||
@self.module.lru_cache(maxsize=None)
|
||||
def fib(n):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue