@lru_cache typechecker fragility (crashes on empty dicts)

Issue #24 new
Thomas Gilgenast created an issue

typical stack trace:

  File "/home/tgg/clean-venv/lib/python2.7/site-packages/lib5c/util/lru_cache.py", line 145, in wrapper
    key = make_key(args, kwds, typed)
  File "/home/tgg/clean-venv/lib/python2.7/site-packages/lib5c/util/lru_cache.py", line 79, in _make_key
    if _typecheck_counts(key_list[i]):
  File "/home/tgg/clean-venv/lib/python2.7/site-packages/lib5c/util/lru_cache.py", line 50, in _typecheck_counts
    return type(counts) == dict and type(counts.keys()[0]) == str and \
IndexError: list index out of range

seems like a low-priority bug since at the current time all functions decorated with @lru_cache aren't expected to succeed when empty dicts are passed to them

Comments (1)

  1. Log in to comment