summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorOsvaldo Santana Neto <osantana@users.noreply.github.com>2017-07-01 17:34:45 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-07-01 17:34:45 (GMT)
commit8a8d28501fc8ce25926d168f1c657656c809fd4c (patch)
treee987cc31628e5c5dd7c4d07fafc9e0464659f0b3 /Lib/os.py
parent85f643023fed3d4e2fb8e399f9ad57f3a65ef237 (diff)
downloadcpython-8a8d28501fc8ce25926d168f1c657656c809fd4c.zip
cpython-8a8d28501fc8ce25926d168f1c657656c809fd4c.tar.gz
cpython-8a8d28501fc8ce25926d168f1c657656c809fd4c.tar.bz2
bpo-30441: Fix bug when modifying os.environ while iterating over it (#2409)
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 e293eca..807ddb5 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -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):