osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Definition of equality check behavior


On Wed, May 08, 2019 at 12:05:07AM +0200, Max Vogler wrote:
> Thanks for starting this discussion and addressing my issue, Jordan.
> 
> I would like to clarify the intentions behind my original issue
> <https://github.com/PythonCharmers/python-future/issues/432>: It does not
> concern coercion in Python's __eq__. Instead, the issue concerns the return
> of False instead of NotImplemented in future.types.newstr.__eq__. 

Unless there is something special about newstr that it should force an 
unequal result, it should return NotImplemented when comparing to types 
it knows nothing about.

I'm reluctant to outright declare a class I know nothing about in a 
library I don't understand is buggy, but on the face of it, if 
newstr.__eq__ doesn't return NotImplemented, it probably is buggy.

If so, newstr is in good company: failure to return NotImplemented is a 
very common bug in third-party code. I've written heaps of classes that 
wrongly force a False result. But I've learned better and don't do it 
any more :-)



-- 
Steven