summaryrefslogtreecommitdiff
path: root/Lib/_collections_abc.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-05-05 11:14:06 +0300
committerRaymond Hettinger <python@rcn.com>2016-05-05 11:14:06 +0300
commit584e8aedc3d66721efcdcbd1a43d4c5b7476427b (patch)
tree55e0a4e70a641ef36665489fac95802d5fba3cb3 /Lib/_collections_abc.py
parentd7062de95d035121abbab526c3b59904361aa256 (diff)
downloadcpython-git-584e8aedc3d66721efcdcbd1a43d4c5b7476427b.tar.gz
Issue 26915: Add identity checks to the collections ABC __contains__ methods.
Diffstat (limited to 'Lib/_collections_abc.py')
-rw-r--r--Lib/_collections_abc.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index d3375847e2..31583731fc 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -689,7 +689,7 @@ class ItemsView(MappingView, Set):
except KeyError:
return False
else:
- return v == value
+ return v is value or v == value
def __iter__(self):
for key in self._mapping:
@@ -704,7 +704,8 @@ class ValuesView(MappingView):
def __contains__(self, value):
for key in self._mapping:
- if value == self._mapping[key]:
+ v = self._mapping[key]
+ if v is value or v == value:
return True
return False
@@ -839,7 +840,7 @@ class Sequence(Sized, Reversible, Container):
def __contains__(self, value):
for v in self:
- if v == value:
+ if v is value or v == value:
return True
return False