summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-08-12 19:45:28 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-08-12 19:45:28 (GMT)
commit92c7b90148fafff423b56950d3f0a9267e7a95ad (patch)
tree948cfd567b4447d9510e5c1c6e9c85f218a6ce17 /Lib/functools.py
parent574d4cfdf61b35e1c3a616a6b61b4707d5ba41e5 (diff)
parent4d58897fdb0f123340246fac79174a52d7cbcf85 (diff)
downloadcpython-92c7b90148fafff423b56950d3f0a9267e7a95ad.zip
cpython-92c7b90148fafff423b56950d3f0a9267e7a95ad.tar.gz
cpython-92c7b90148fafff423b56950d3f0a9267e7a95ad.tar.bz2
merge
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index 4538057..c1ca850 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -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