mirror of
https://github.com/python/cpython.git
synced 2025-10-08 08:01:55 +00:00
bpo-30441: Fix bug when modifying os.environ while iterating over it (#2409)
This commit is contained in:
parent
85f643023f
commit
8a8d28501f
4 changed files with 29 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue