Commit 165f26c3 authored by Martin v. Löwis's avatar Martin v. Löwis

Avoid using items() in environ.update(). Fixes #1124513.

Will backport to 2.4.
parent 8b44fb78
......@@ -445,12 +445,17 @@ else:
def update(self, dict=None, **kwargs):
if dict:
try:
items = dict.items()
keys = dict.keys()
except AttributeError:
# List of (key, value)
items = dict
for k, v in items:
for k, v in dict:
self[k] = v
else:
# got keys
# cannot use items(), since mappings
# may not have them.
for k in keys:
self[k] = dict[k]
if kwargs:
self.update(kwargs)
def copy(self):
......@@ -467,12 +472,17 @@ else:
def update(self, dict=None, **kwargs):
if dict:
try:
items = dict.items()
keys = dict.keys()
except AttributeError:
# List of (key, value)
items = dict
for k, v in items:
for k, v in dict:
self[k] = v
else:
# got keys
# cannot use items(), since mappings
# may not have them.
for k in keys:
self[k] = dict[k]
if kwargs:
self.update(kwargs)
try:
......
......@@ -227,7 +227,7 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
os.environ.update(self.__save)
# Bug 1110478
def test_update(self):
def test_update2(self):
if os.path.exists("/bin/sh"):
os.environ.update(HELLO="World")
value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment