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 internal crash when resolve same partial type twice #14552

Merged
merged 3 commits into from
Jan 29, 2023

Conversation

uriyyo
Copy link
Member

@uriyyo uriyyo commented Jan 29, 2023

Fixes: #14548

Fixed case when untyped list item type resolving can lead to an internal crash.

Code to reproduce this issue:

arr = []
arr.append(arr.append(1))

Basically, the issue is that after the first resolving of arr.append method, var is deleted from partial_types, and as war as arr.append is a nested call we try to delete the same var that was already deleted.

@github-actions

This comment has been minimized.

arr = []
arr.append(arr.append(1))
[out]
main:3: error: "List[int]" has no attribute "append"
Copy link
Member

Choose a reason for hiding this comment

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

It's better than a crash (thanks for filing this PR!), but this error still doesn't make sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

@JelleZijlstra You are right, that is because I forgot to add fixtures to a test. Fixed, please, review again.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! I guess when there's something weird going on in a mypy test there's a 90% chance it's due to a fixture.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 91e8581 into python:master Jan 29, 2023
hauntsaninja pushed a commit to hauntsaninja/mypy that referenced this pull request Jan 29, 2023
Fixes: python#14548

Fixed case when untyped list item type resolving can lead to an internal
crash.

Code to reproduce this issue:
```py
arr = []
arr.append(arr.append(1))
```

Basically, the issue is that after the first resolving of `arr.append`
method, `var` is deleted from `partial_types`, and as war as
`arr.append` is a nested call we try to delete the same `var` that was
already deleted.
hauntsaninja added a commit that referenced this pull request Jan 29, 2023
#14552) (#14553)

Fixes: #14548

Fixed case when untyped list item type resolving can lead to an internal
crash.

Code to reproduce this issue:
```py
arr = []
arr.append(arr.append(1))
```

Basically, the issue is that after the first resolving of `arr.append`
method, `var` is deleted from `partial_types`, and as war as
`arr.append` is a nested call we try to delete the same `var` that was
already deleted.

Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
@uriyyo uriyyo deleted the fix-14548 branch February 7, 2023 13:28
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.

Crash with BeautifulSoup
2 participants