Open
Description
Bug report
Bug description:
Consider this example:
>>> class A: ... def __str__(self): return "some random text" ... def __call__(self, a): ... >>> A()() Traceback (most recent call last): File "<python-input-16>", line 1, in <module> A()() ~~~^^ TypeError: A.__call__() missing 1 required positional argument: 'a' >>> A()(*None) Traceback (most recent call last): File "<python-input-17>", line 1, in <module> A()(*None) ~~~^^^^^^^ TypeError: some random text argument after * must be an iterable, not NoneType
The first one gets the callable's __qualname__
. The second, on the other hand, does not, but should do so.
Another example, mentioned in #135975 (issuecomment link):
>>> exit(*None) Traceback (most recent call last): File "<python-input-0>", line 1, in <module> exit(*None) ~~~~^^^^^^^ TypeError: Use exit() or Ctrl-Z plus Return to exit argument after * must be an iterable, not NoneType
Which just gets the exit
's __repr__
.
If this is recognized as unwanted behaviour, I'm ready to make a PR.
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Edit: ** also does not work properly:
# the code from the first example >>> A()(**1) Traceback (most recent call last): File "<python-input-26>", line 1, in <module> A()(**1) ~~~^^^^^ TypeError: some random text argument after ** must be a mapping, not int