Skip to content

[mypyc] Fix comparison of tuples with different lengths #19372

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

Merged
merged 2 commits into from
Jul 4, 2025

Conversation

p-sawicki
Copy link
Contributor

When comparing tuples, their lengths are now compared and their contents are only compared if their lengths are equal. Otherwise, when they have different lengths, the comparison always evaluates to False.

@brianschubert
Copy link
Member

Good find! I can confirm that this is a bug; (1,) == (1, 2) is True and (1, 2) == (1,) crashes on master.

@brianschubert brianschubert added the topic-mypyc mypyc bugs label Jul 3, 2025
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

@JukkaL JukkaL merged commit 1a99ce2 into python:master Jul 4, 2025
13 checks passed
@p-sawicki p-sawicki deleted the p-sawicki/tuple-comparison branch July 4, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-mypyc mypyc bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants