Skip to content

Commit 8086aa5

Browse files
committed
Check type of 'maxsize' in cached_method
1 parent 981013b commit 8086aa5

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/functools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,9 @@ def _get_or_create_cached_func(self, instance):
11971197

11981198

11991199
def cached_method(func=None, /, maxsize=None, typed=False):
1200+
if maxsize is not None and not isinstance(maxsize, int) and not callable(maxsize):
1201+
raise TypeError(
1202+
'Expected maxsize to be an integer, a callable, or None')
12001203
if func is None:
12011204
def decorator(func):
12021205
return _cached_method(func, maxsize=maxsize, typed=typed)

0 commit comments

Comments
 (0)