diff options
author | Yury Selivanov <yury@magic.io> | 2016-11-09 23:56:26 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-11-09 23:56:26 (GMT) |
commit | 0a66a1cdd61ce7239298e19c938b05ade99cde8a (patch) | |
tree | a0c5960f506eb71da05f090f7adf7e0e1ff17271 /Lib/test/test_functools.py | |
parent | 04c954d2754e917c037c032579ee5aa95da6529e (diff) | |
parent | 46a02db90b295bfec1712515e09aeda31bbe84e0 (diff) | |
download | cpython-0a66a1cdd61ce7239298e19c938b05ade99cde8a.zip cpython-0a66a1cdd61ce7239298e19c938b05ade99cde8a.tar.gz cpython-0a66a1cdd61ce7239298e19c938b05ade99cde8a.tar.bz2 |
Merge 3.6 (issue #28653)
Diffstat (limited to 'Lib/test/test_functools.py')
-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 9ea6747..75427df 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): |