mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
merge
This commit is contained in:
commit
c28dbd0452
3 changed files with 20 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
import abc
|
||||
import builtins
|
||||
import collections
|
||||
import copy
|
||||
from itertools import permutations
|
||||
|
@ -1189,6 +1190,18 @@ class TestLRU:
|
|||
self.assertEqual(misses, 4)
|
||||
self.assertEqual(currsize, 2)
|
||||
|
||||
def test_lru_reentrancy_with_len(self):
|
||||
# Test to make sure the LRU cache code isn't thrown-off by
|
||||
# caching the built-in len() function. Since len() can be
|
||||
# cached, we shouldn't use it inside the lru code itself.
|
||||
old_len = builtins.len
|
||||
try:
|
||||
builtins.len = self.module.lru_cache(4)(len)
|
||||
for i in [0, 0, 1, 2, 3, 3, 4, 5, 6, 1, 7, 2, 1]:
|
||||
self.assertEqual(len('abcdefghijklmn'[:i]), i)
|
||||
finally:
|
||||
builtins.len = old_len
|
||||
|
||||
def test_lru_type_error(self):
|
||||
# Regression test for issue #28653.
|
||||
# lru_cache was leaking when one of the arguments
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue