Skip to content

Commit 224168a

Browse files
authored
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__`.
1 parent a1b35bb commit 224168a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

rest_framework/exceptions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ def __eq__(self, other):
8181
return r
8282

8383
def __ne__(self, other):
84-
return not self.__eq__(other)
84+
r = self.__eq__(other)
85+
if r is NotImplemented:
86+
return NotImplemented
87+
return not r
8588

8689
def __repr__(self):
8790
return 'ErrorDetail(string=%r, code=%r)' % (

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy