-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
None __ne__ behavior changes in 3.12 #112125
Comments
What's the scenario where you're calling The recommendation is to not call dunder methods directly. |
Out of curiosity, I tracked this down to commit 432117c, which just gave |
I ran into this issue with code such as |
rhettinger also showed that use case / idiom previously: |
The list comprehension requires materializing the result in memory, but if we want to say that using |
At first, I couldn't see how this edit would have caused a visible behavior change. I think what is happening is that we used to inherit I would like to see the The goal of the previous edit was simply to make the hash value constant. The code review did not detect the downstream effect on |
We also got hit by this pretty bad, using Just to clarify, @rhettinger, is this a canonical recommended idiom and we've just got hit by a bus, or it's a cool hack that's bound to fail randomly and the "supported" idiom would be |
@zyv In the latter case you might want to use |
@zyv The comparison While it is permissible (and fast) to call the dunder methods in code like If instead you write |
…ad of False (python#112504) (cherry picked from commit 9c3458e)
I merged your PR, thank you @andrewluotechnologies. I backported the change manually to 3.12 to fix a merge conflict. |
Bug report
Bug description:
In 3.11,
None.__ne__(None)
returnedFalse
but in 3.12 it returnsNotImplemented
. This is a breaking behavior change that is either a bug or should be documented.CPython versions tested on:
3.11, 3.12
Operating systems tested on:
Windows
Linked PRs
The text was updated successfully, but these errors were encountered: