Skip to content

Commit 79c37d0

Browse files
authored
Return NotImplemented sooner for ErrorDetail equality test (#7531)
The test suite raises warnings when tested against Python 3.9 `DeprecationWarning: NotImplemented should not be used in a boolean context` Where `r` returns `NotImplemented` then this change returns `NotImplemented` first to avoid the comparison test.
1 parent 79daf31 commit 79c37d0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rest_framework/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def __new__(cls, string, code=None):
7373

7474
def __eq__(self, other):
7575
r = super().__eq__(other)
76+
if r is NotImplemented:
77+
return NotImplemented
7678
try:
7779
return r and self.code == other.code
7880
except AttributeError:

0 commit comments

Comments
 (0)