summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-07-04 04:55:32 (GMT)
committerGitHub <noreply@github.com>2017-07-04 04:55:32 (GMT)
commitbebd2cfa5f21811dd0ee4f3b1a1b85d379b83436 (patch)
treeb089cbbaf1aa59ae16419beb7523a6a57dfe1c1f /Lib/os.py
parent4132adb4b8f90893d8f19ff46edff56f189faca0 (diff)
downloadcpython-bebd2cfa5f21811dd0ee4f3b1a1b85d379b83436.zip
cpython-bebd2cfa5f21811dd0ee4f3b1a1b85d379b83436.tar.gz
cpython-bebd2cfa5f21811dd0ee4f3b1a1b85d379b83436.tar.bz2
[3.6] bpo-30441: Fix bug when modifying os.environ while iterating over it (GH-2409). (#2556)
(cherry picked from commit 8a8d28501fc8ce25926d168f1c657656c809fd4c)
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/os.py b/Lib/os.py
index fa06f39..9fa8acb 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -685,7 +685,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):