summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index d5f4393..b3428a4 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