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

Will backport to 2.4.
This commit is contained in:
Martin v. Löwis 2005-02-17 21:23:20 +00:00
parent 3040b19976
commit 5510f65f5a
2 changed files with 19 additions and 9 deletions

View file

@ -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:
self[k] = v
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:
self[k] = v
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: