Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Inconsistent TypeError messages with callables #136327

Open
Assignees
sobolevnTapeline
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@Tapeline

Description

@Tapeline

Bug report

Bug description:

Consider this example:

>>>classA:...def__str__(self):return"some random text"...def__call__(self,a): ...>>>A()()Traceback (mostrecentcalllast):File"<python-input-16>",line1,in<module>A()()~~~^^TypeError:A.__call__()missing1requiredpositionalargument:'a'>>>A()(*None)Traceback (mostrecentcalllast):File"<python-input-17>",line1,in<module>A()(*None)~~~^^^^^^^TypeError:somerandomtextargumentafter*mustbeaniterable,notNoneType

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 (mostrecentcalllast):File"<python-input-0>",line1,in<module>exit(*None)~~~~^^^^^^^TypeError:Useexit()orCtrl-ZplusReturntoexitargumentafter*mustbeaniterable,notNoneType

Which just gets theexit'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 (mostrecentcalllast):File"<python-input-26>",line1,in<module>A()(**1)~~~^^^^^TypeError:somerandomtextargumentafter**mustbeamapping,notint

Linked PRs

Metadata

Metadata

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp