[New-bugs-announce] [issue28260] mock._Any and mock._Call implement __eq__ but not __hash__

Roy Williams report at bugs.python.org
Fri Sep 23 13:59:53 EDT 2016


New submission from Roy Williams:

I am investigating a migration to Python 3, and to facilitate this we are using the -3 flag as decribed here: https://docs.python.org/3/howto/pyporting.html#prevent-compatibility-regressions . When using this flag I encountered
some issues inside of mock itself.

Python 3 now requires you to implement __hash__ if you implement __eq__. See https://docs.python.org/3.6/reference/datamodel.html#object.%5F%5Fhash%5F%5F .

{mock.ANY}  # Fine in Python 2, Throws in Python 3

I've created a PR that explicitly sets the __hash__ method on these objects as None to ensure the behavior is consistent in Python 3 as well as Python 2.  The folks over at testing-in-python suggested I submit a bug here first and then the fix can be backported to testing-cabal/mock

https://github.com/testing-cabal/mock/pull/378

----------
components: Library (Lib)
messages: 277290
nosy: Roy Williams
priority: normal
severity: normal
status: open
title: mock._Any and mock._Call implement __eq__ but not __hash__
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28260>
_______________________________________


More information about the New-bugs-announce mailing list