Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on Callable self in __call__ #16453

Merged
merged 1 commit into from
Nov 11, 2023

Conversation

ilevkivskyi
Copy link
Member

Fixes #16450

The fix is a bit ad-hoc, but OTOH there is nothing meaningful we can infer in such situation, so it is probably OK.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py): typechecking got 1.08x slower (148.8s -> 160.3s)
(Performance measurements are based on a single noisy sample)

@jepler
Copy link

jepler commented Nov 11, 2023

I checked and this resolves the crash on my original source! thank you.

# Having a def __call__(self: Callable[...], ...) can cause infinite recursion. Although
# this special-casing looks not very principled, there is nothing meaningful we can infer
# from such definition, since it is inherently indefinitely recursive.
allow_callable = func.name is None or not func.name.startswith("__call__ of")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"__call__ of" looks weird to me -- mind telling me what's going on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just how names work for methods.

@ilevkivskyi ilevkivskyi merged commit c68bd7a into python:master Nov 11, 2023
18 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-self-call-crash branch November 11, 2023 12:59
@ilevkivskyi ilevkivskyi mentioned this pull request Nov 11, 2023
2 tasks
JukkaL pushed a commit that referenced this pull request Nov 22, 2023
Fixes #16450

The fix is a bit ad-hoc, but OTOH there is nothing meaningful we can
infer in such situation, so it is probably OK.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mypy 1.7.0 crashes (segmentation fault)
3 participants