bpo-30441: Fix bug when modifying os.environ while iterating over it (#2409)

This commit is contained in:
Osvaldo Santana Neto 2017-07-01 14:34:45 -03:00 committed by Serhiy Storchaka
parent 85f643023f
commit 8a8d28501f
4 changed files with 29 additions and 1 deletions

View file

@ -697,7 +697,9 @@ class _Environ(MutableMapping):
raise KeyError(key) from None
def __iter__(self):
for key in self._data:
# list() from dict object is an atomic operation
keys = list(self._data)
for key in keys:
yield self.decodekey(key)
def __len__(self):