summaryrefslogtreecommitdiff
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 9ea6747188..75427dfad3 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1189,6 +1189,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):