mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
exceptions.ErrorDetail: Handle NotImplemented
correctly in __ne__
(#8538)
PR #7531 resolved issue #7433 by updating `ErrorDetails.__eq__` to correctly handle the `NotImplemented` case. However, Python 3.9 continues to issue the following warning: DeprecationWarning: NotImplemented should not be used in a boolean context This is because `__ne__` still doesn't handle the `NotImplemented` case correctly. In order to avoid this warning, this commit makes the same change for `__ne__` as previously made for `__eq__`.
This commit is contained in:
parent
a1b35bb44b
commit
224168a28f
|
@ -81,7 +81,10 @@ class ErrorDetail(str):
|
|||
return r
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
r = self.__eq__(other)
|
||||
if r is NotImplemented:
|
||||
return NotImplemented
|
||||
return not r
|
||||
|
||||
def __repr__(self):
|
||||
return 'ErrorDetail(string=%r, code=%r)' % (
|
||||
|
|
Loading…
Reference in New Issue
Block a user