mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue 22184: Early detection and reporting of missing lru_cache parameters
This commit is contained in:
parent
4d83192ea0
commit
4d58897fdb
3 changed files with 16 additions and 0 deletions
|
|
@ -392,6 +392,12 @@ def lru_cache(maxsize=128, typed=False):
|
|||
# The internals of the lru_cache are encapsulated for thread safety and
|
||||
# to allow the implementation to change (including a possible C version).
|
||||
|
||||
# Early detection of an erroneous call to @lru_cache without any arguments
|
||||
# resulting in the inner function being passed to maxsize instead of an
|
||||
# integer or None.
|
||||
if maxsize is not None and not isinstance(maxsize, int):
|
||||
raise TypeError('Expected maxsize to be an integer or None')
|
||||
|
||||
# Constants shared by all lru cache instances:
|
||||
sentinel = object() # unique object used to signal cache misses
|
||||
make_key = _make_key # build a key from the function arguments
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue