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

Some improvements to __richcmp__ on enums #2622

Merged
merged 2 commits into from Sep 19, 2022
Merged

Some improvements to __richcmp__ on enums #2622

merged 2 commits into from Sep 19, 2022

Conversation

SquidDev
Copy link
Contributor

@SquidDev SquidDev commented Sep 14, 2022

  • Implement __ne__ as well as __eq__. Fixes __ne__ always returns True for enums #2618.
  • Return NotImplemented when types cannot be converted, rather than throwing.
  • Compare the integer ids inside the eq/ne implementation. Previously a match block was generated - this is now closer to what #[derive(PartialEq)] would generate.

@SquidDev
Copy link
Contributor Author

I don't believe the build failure here is due to this change. From what I can tell the same failure has happened on a couple of other PRs.

@adamreichold
Copy link
Member

I don't believe the build failure here is due to this change. From what I can tell the same failure has happened on a couple of other PRs.

Indeed. But it should also be fixed on the current main. Could you rebase your PR?

 - Implement __ne__ as well as __eq__.
 - Return NotImplemented when types cannot be converted, rather than
   throwing.
 - Compare the integer ids inside the __eq__/__ne__ implementation.
   Previously a match block was generated.
Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good to me, though it needs a news entry please - newsfragments/2622.fixed.md.

@davidhewitt davidhewitt merged commit 54d4732 into PyO3:main Sep 19, 2022
@SquidDev SquidDev deleted the hotfix/enum-eq branch September 19, 2022 16:14
@SquidDev
Copy link
Contributor Author

SquidDev commented Sep 19, 2022

Thank you for merging :).

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.

__ne__ always returns True for enums
3 participants