From 1e1bce5c3849f87c7fb0ecc5eb545bfeed64d28e Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Wed, 29 Jul 2020 13:35:33 +0000 Subject: [PATCH] Fix deprecation warning regarding NotImplemented being evaluated in boolean context. --- rest_framework/exceptions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 345a40524..8c9d8f8ec 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -74,7 +74,10 @@ class ErrorDetail(str): def __eq__(self, other): r = super().__eq__(other) try: - return r and self.code == other.code + if r is not NotImplemented: + return r and self.code == other.code + else: + return self.code == other.code except AttributeError: return r