diff options
| author | Dong-hee Na <donghee.na92@gmail.com> | 2018-07-10 16:26:36 +0900 |
|---|---|---|
| committer | INADA Naoki <methane@users.noreply.github.com> | 2018-07-10 16:26:36 +0900 |
| commit | 445f1b35ce8461268438c8a6b327ddc764287e05 (patch) | |
| tree | 7946f28321ff39563a8200ed7705a600f7ab521a /Lib/functools.py | |
| parent | 7762e4d3872818272800dfbd8e1d8e3a689eb8f2 (diff) | |
| download | cpython-git-445f1b35ce8461268438c8a6b327ddc764287e05.tar.gz | |
bpo-33967: Fix singledispatch raised IndexError when no args (GH-8184)
Diffstat (limited to 'Lib/functools.py')
| -rw-r--r-- | Lib/functools.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index d5f43935e6..b3428a4ca2 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -817,8 +817,13 @@ def singledispatch(func): return func def wrapper(*args, **kw): + if not args: + raise TypeError(f'{funcname} requires at least ' + '1 positional argument') + return dispatch(args[0].__class__)(*args, **kw) + funcname = getattr(func, '__name__', 'singledispatch function') registry[object] = func wrapper.register = register wrapper.dispatch = dispatch |
