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 when checking slice expression with step 0 in tuple index #18063

Merged

Conversation

brianschubert
Copy link
Collaborator

Fixes #18062

I plan to follow up with another PR that adds a better error messages for slice expressions with step=0 when indexing standard containers that disallow that.

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@brianschubert
Copy link
Collaborator Author

Python 3.8 failure on Windows looks like a flake.

Comment on lines +1443 to +1444
# TODO: emit better error when 0 is used for step
()[::0] # E: Ambiguous slice of a variadic tuple
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If #18065 gets merged, this test will change:

Suggested change
# TODO: emit better error when 0 is used for step
()[::0] # E: Ambiguous slice of a variadic tuple
()[::0] # E: Slice step cannot be 0

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, makes sense to do the simplest fix for a crash first

@hauntsaninja hauntsaninja merged commit 654ae20 into python:master Oct 29, 2024
18 of 19 checks passed
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 when checking slice expression with 0 used for the step
2 participants