-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The C implementation of functools.lru_cache checks whether its argument is callable and raises an exception if not. The Python version does not do that:
import sys
sys.modules['_functools'] = None
import functools
functools.lru_cache()(1) # does not raisewithout blocking the import of _functools you get:
Traceback (most recent call last):
File "/home/cfbolz/projects/cpython/functoolserror.py", line 5, in <module>
functools.lru_cache()(1)
~~~~~~~~~~~~~~~~~~~~~^^^
File "/home/cfbolz/projects/cpython/Lib/functools.py", line 598, in decorating_function
wrapper = _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo)
TypeError: the first argument must be callable
I think this should simply be fixed in the Python implementation and will prepare a patch.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error