]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-37555: Replacing __eq__ with == to sidestep NotImplemented
authorElizabeth Uselton <elizabeth.uselton@rover.com>
Sat, 20 Jul 2019 03:45:52 +0000 (20:45 -0700)
committerElizabeth Uselton <elizabeth.uselton@rover.com>
Sat, 20 Jul 2019 03:45:52 +0000 (20:45 -0700)
bool(NotImplemented) returns True, so it's necessary to use ==
instead of __eq__ in this comparison.

Lib/unittest/mock.py

index f91836554107b18223f15e37675b088015d585ab..aff5e70065a01e92b601b90f043f0fe9ff35ad74 100644 (file)
@@ -348,7 +348,7 @@ class _CallList(list):
         self_list = list(self)
         other_list = list(other)
         # checking equality both directions is necessary for ANY to work
-        return self_list.__eq__(other_list) or other_list.__eq__(self_list)
+        return self_list == other_list or other_list == self_list
 
 
 def _check_and_set_parent(parent, value, name, new_name):
@@ -2411,8 +2411,8 @@ class _Call(tuple):
         self_params = self_args, self_kwargs
         other_params = other_args, other_kwargs
         return (
-            self_params.__eq__(other_params)
-            or other_params.__eq__(self_params)
+            self_params == other_params
+            or other_params == self_params
         )