Skip to content

Commit f295eac

Browse files
committed
bpo-37555: Replacing __eq__ with == to sidestep NotImplemented
bool(NotImplemented) returns True, so it's necessary to use == instead of __eq__ in this comparison.
1 parent f0e8411 commit f295eac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/unittest/mock.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def __eq__(self, other):
348348
self_list = list(self)
349349
other_list = list(other)
350350
# checking equality both directions is necessary for ANY to work
351-
return self_list.__eq__(other_list) or other_list.__eq__(self_list)
351+
return self_list == other_list or other_list == self_list
352352

353353

354354
def _check_and_set_parent(parent, value, name, new_name):
@@ -2411,8 +2411,8 @@ def __eq__(self, other):
24112411
self_params = self_args, self_kwargs
24122412
other_params = other_args, other_kwargs
24132413
return (
2414-
self_params.__eq__(other_params)
2415-
or other_params.__eq__(self_params)
2414+
self_params == other_params
2415+
or other_params == self_params
24162416
)
24172417

24182418

0 commit comments

Comments
 (0)