summaryrefslogtreecommitdiffstats
path: root/Lib/collections
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/collections')
-rw-r--r--Lib/collections/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index f0b41fd..9a753db 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -920,7 +920,10 @@ class ChainMap(_collections_abc.MutableMapping):
return len(set().union(*self.maps)) # reuses stored hash values if possible
def __iter__(self):
- return iter(set().union(*self.maps))
+ d = {}
+ for mapping in reversed(self.maps):
+ d.update(mapping) # reuses stored hash values if possible
+ return iter(d)
def __contains__(self, key):
return any(key in m for m in self.maps)