[New-bugs-announce] [issue33967] functools.singledispatch: Misleading exception when calling without arguments
Walter Dörwald
report at bugs.python.org
Tue Jun 26 07:57:10 EDT 2018
New submission from Walter Dörwald <walter at livinglogic.de>:
When I call a function decorated with functools.singledispatch without an argument, I get the following:
$ python
Python 3.6.5 (default, Jun 17 2018, 12:13:06)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
>>> @functools.singledispatch
... def f(x):
... pass
...
>>> f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/functools.py", line 803, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
IndexError: tuple index out of range
I would have expected a TypeError along the lines of
TypeError: f() missing 1 required positional argument: 'x'
----------
components: Library (Lib)
messages: 320485
nosy: doerwalter
priority: normal
severity: normal
status: open
title: functools.singledispatch: Misleading exception when calling without arguments
type: behavior
versions: Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33967>
_______________________________________
More information about the New-bugs-announce
mailing list