Playing around with the LRUCache I noticed a issue with copying. Seems to be a small issue with forgetting to call post LRUCache._postinitafter copying the deque. Not sure if this is being felt elsewhere as I couldn't quickly see any instances of the cache being copied.
Expected Behavior
Performing __setitem__ on a copied (copy.copy or LRUCache.copy) should remove the oldest item from the cache.
Actual Behavior
Throws Index Error: pop from an empty deque
Full Traceback
>>> from jinja2 import utils
>>> cache = utils.LRUCache(1)
>>> cache['foo'] = 'bar'
>>> copy = cache.copy()
>>> copy['blah'] = 'blargh'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "jinja2/utils.py", line 424, in __setitem__
del self._mapping[self._popleft()]
IndexError: pop from an empty deque
>>> copy._popleft
<built-in method popleft of collections.deque object at 0x10160d670>
>>> copy._queue.popleft
<built-in method popleft of collections.deque object at 0x101635360>
Your Environment
Python version: 2.7
Jinja version: 2.11.dev
Playing around with the LRUCache I noticed a issue with copying. Seems to be a small issue with forgetting to call post
LRUCache._postinitafter copying the deque. Not sure if this is being felt elsewhere as I couldn't quickly see any instances of the cache being copied.Expected Behavior
Performing
__setitem__on a copied (copy.copyorLRUCache.copy) should remove the oldest item from the cache.Actual Behavior
Throws
Index Error: pop from an empty dequeFull Traceback
Your Environment
Python version: 2.7
Jinja version: 2.11.dev