One function

TTLCache in tkem/cachetools

The author described this change as Fix #12: No formatting of KeyError arguments.. It counts as a record because the check below fails on the code as it stood at ba0f84954 and passes on d5ef9cc6f, with nothing else changed between the two runs.

Fix saved2014-09-25
Sharing licenceMIT · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Cache implementation with per-item time-to-live (TTL) value. This class associates a time-to-live value with each item. Items that expire because they have exceeded their time-to-live will be removed automatically. If no expired items are there to remove, the least recently used items will be discarded first to make space when necessary.

The change

3232 def __getitem__(self, key, cache_getitem=LRUCache.__getitem__):
3333 value, link = cache_getitem(self, key)
3434 if link.data[1] < self.__timer():
35- raise KeyError('%r has expired' % key)
35+ raise KeyError(key)
3636 return value
3737
3838 def __setitem__(self, key, value,

The check that tells the two apart

failpass·tests/test_ttlcache.py::TTLCacheTest::test_ttl_tuple_key

Check file tests/test_ttlcache.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itba0f849543155f76caf2107e9a8108e56d0604e1
Broken version dated2014-09-23
Modulecachetools.ttlcache
Units changedTTLCache
Fingerprint3a9eafb468266b30
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in tkem/cachetools