[Python-checkins] python/dist/src/Lib os.py,1.85,1.86

loewis at users.sourceforge.net loewis at users.sourceforge.net
Thu Feb 17 22:23:32 CET 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1766/Lib

Modified Files:
	os.py 
Log Message:
Avoid using items() in environ.update(). Fixes #1124513.
Will backport to 2.4.


Index: os.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- os.py	29 Jan 2005 13:29:22 -0000	1.85
+++ os.py	17 Feb 2005 21:23:20 -0000	1.86
@@ -445,12 +445,17 @@
             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 @@
             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:



More information about the Python-checkins mailing list