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
"Interface.__eq__" ignores the "Interface" semantics and renders dynamic interface definitions unreliable #218
Comments
Taking into account that hashing and equality are called very very often in the code, I am also +1 for good documentation but keeping the current state of implementation. Performance wise it works fine. |
Because the example is unrealistic, ignores pickling/persistence, only results in problems in extremely rare corner cases, and has been the status quo for a decade, I do not consider this to be a significant problem. I consider the existing documentation adequate. I feel there is no need for "a big warning." |
I would not add a big warning, just I think it would be good to mention explicit that (like in the context of mocking for testing):
will let you run into problems. |
Jason Madden wrote at 2020-10-1 03:22 -0700:
Because the example is unrealistic, ignores pickling/persistence, only results in problems in extremely rare corner cases, and has been the status quo for a decade, I do not consider this to be a significant problem.
I consider [the existing documentation](https://zopeinterface.readthedocs.io/en/latest/api/specifications.html#equality-hashing-and-comparisons) adequate. I feel there is no need for "a big warning."
You seem to disregard that the problem has occured in a real (test) case
and that is was difficult to analyze.
I am always very wary about problems that can occur apparently non
deterministically -- in the case above, the problem was observed only
for one Python version and apparently depended on when the
garbage collector became active.
Such problems can require an huge amount of analysis effort
and should (in my view) be avoided whenever possible.
|
The |
5.2.0 (2020-11-05) ================== - Add documentation section ``Persistency and Equality`` (`openembedded#218 <https://github.com/zopefoundation/zope.interface/issues/218>`_). - Create arm64 wheels. - Add support for Python 3.9. Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
5.2.0 (2020-11-05) ================== - Add documentation section ``Persistency and Equality`` (`openembedded#218 <https://github.com/zopefoundation/zope.interface/issues/218>`_). - Create arm64 wheels. - Add support for Python 3.9. Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
5.2.0 (2020-11-05) ================== - Add documentation section ``Persistency and Equality`` (`openembedded#218 <https://github.com/zopefoundation/zope.interface/issues/218>`_). - Create arm64 wheels. - Add support for Python 3.9. Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
5.2.0 (2020-11-05) ================== - Add documentation section ``Persistency and Equality`` (`openembedded#218 <https://github.com/zopefoundation/zope.interface/issues/218>`_). - Create arm64 wheels. - Add support for Python 3.9. Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
5.2.0 (2020-11-05) ================== - Add documentation section ``Persistency and Equality`` (`#218 <https://github.com/zopefoundation/zope.interface/issues/218>`_). - Create arm64 wheels. - Add support for Python 3.9. Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com> Acked-by: Trevor Gamblin <trevor.gamblin@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Interface.__eq__
is only based on__name__
and__module__
. This results in a very surprising notion of equality as the following code demonstrates:i.e. the interface
I1
is considered equal to the "normal" (non Interface) classI
.This renders local (i.e. in a function body) interface definitions unreliable as
#216 (comment)
(and following comments) demonstrates. The resulting errors can be non-deterministic and very difficult to analyze.
@jamadden explains in #216 that
__eq__
is defined as it is in order to allow interfaces to be used as keys inBTrees
. This may justify the definition however due to the potentially very difficult errors which may result from local interface definitions it should be clearly documented (which currently is not the case) with a big warning regarding the implication for local interface definitions (or overridden interface definitions as in the example above).The text was updated successfully, but these errors were encountered: