Closed dataflake closed 7 years ago
The use case would be to use a brain record as a dictionary key, or to add one or more to a set. I would guess we could look at ZCatalog to see how it might use them.
If needed:
def __hash__(self):
return hash(self.__data__)
I couldn't find any explicitly defined __hash__
method defined in ExtensionClass.Base, so my guess is that some built-in fallback hashing mechanism is used which is different between Python2 and Python3.
Experimenting at the command line showed that simply hashing __data__
won't be enough. Currently under Python 2, even Record objects with the same __data__
and identical __record_schema__
hash differently.
A __hash__
method that will show similar behavior and hash any record object uniquely:
def __hash__(self):
return hash(str(self))
What do you think?
https://github.com/zopefoundation/Products.ZSQLMethods/blob/master/src/Shared/DC/ZRDB/tests/test_results.py#L142
This test wants to use the built-in hash function to assert that the
r
class is hashable. This works under Python 2. Under Python 3 this happens:I'm not sure what that test is trying to prove. Is it bogus?
(This is the last failing test on my local Python 3 compatibility branch)