Closed
Description
The __eq__
method of Unit
attempts to convert any value it is compared with to a Unit
. The problem is when this fails it should return NotImplemented
(or raise NotImplementedError
) instead of raising ValueError
. Because of this, comparisons such as:
Unit('meter') == {}
raises
ValueError: [UT_UNKNOWN] Failed to parse unit "{}": b'Resource temporarily unavailable'
when it should return False
. By returning NotImplemented
you can punt the decision to the other object or fall back on object identity (if neither object can handle the comparison).