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
Regression with __hash__ definition and rich comparison operators #45890
Comments
A new behavior was introduced in r59106 in python trunk, which look >>> class A(object):
... def __init__(self, b):
... self.b = b
... def __cmp__(self, other):
... if not isinstance(other, A):
... return -1
... return cmp(self.b, other.b)
...
>>> hash(A(2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable The problematic change is here: And mainly the overrides_hash call in inherit_slots. FWIW, I've encounter the problem because zope.interface is now usable on |
Of course, I meant unusable. |
Also, to be more clear, that happens when you define any of the |
This was done intentionally -- if you define a comparison without Can you give more details about the Zope issue? I agree that needs to |
zope.interface.interface.InterfaceClass implements __lt__ and __gt__. Disabling __hash__ when __cmp__ or __eq__ is defined makes sense, but it |
You have a point. Can you suggest a patch that fixes this? Question though -- what semantics are used for __lt__ and __gt__ that |
It implements ordering based on the interface's fully-qualified Python |
Fair enough. Still, this would go much faster if someone other than myself could be |
There are different ways to fix this. Reverting r59016 is one of them, From what I understand of the changes, removing the operations (lt, I'll try tomorrow, you assign this to me if you want. |
Well, the name_op array is used for other purposes. Perhaps the main |
I gave it a try. The following patch corrects 2 problems:
I've restricted the hash_name_op to the bare minimum, but no tests Please review. |
This is probably not the best moment (holidays etc), but please take Also, zope is not the only one affected, storm seems to suffer from the If this problem isn't solved in a reasonable time, it really questions Thanks. |
To be honest, I have no idea what pybots is, and how it's affected. |
Committed revision 59576. |
Thanks a lot! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: