From c61c04a25f016bdb97653a2de2b8d24f59891b06 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Thu, 6 Aug 2020 16:05:39 +0000 Subject: [PATCH] Fix NotImplemented code path to return NotImplemented itself. --- rest_framework/exceptions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 8c9d8f8ec..9be410abe 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -73,11 +73,12 @@ class ErrorDetail(str): def __eq__(self, other): r = super().__eq__(other) + + if r is NotImplemented: + return r + try: - if r is not NotImplemented: - return r and self.code == other.code - else: - return self.code == other.code + return r and self.code == other.code except AttributeError: return r