diff options
| author | Yury Selivanov <yury@magic.io> | 2016-11-09 18:55:45 -0500 |
|---|---|---|
| committer | Yury Selivanov <yury@magic.io> | 2016-11-09 18:55:45 -0500 |
| commit | 46a02db90b295bfec1712515e09aeda31bbe84e0 (patch) | |
| tree | f9c528e4230c67e830ea1eadd176a0a22b63b14d /Lib | |
| parent | 28f42fd4f813b4be15b47629c557ef8f958727cb (diff) | |
| download | cpython-git-46a02db90b295bfec1712515e09aeda31bbe84e0.tar.gz | |
Issue #28653: Fix a refleak in functools.lru_cache.
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/test/test_functools.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 5076644952..6a3bf64963 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -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): |
