]> granicus.if.org Git - python/commitdiff
Milton L. Hankin reports that on Windows it is possible to have two
authorGuido van Rossum <guido@python.org>
Fri, 2 Jul 1999 02:54:02 +0000 (02:54 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 2 Jul 1999 02:54:02 +0000 (02:54 +0000)
different values in the environ dict with the same key (although he
couldn't explain exactly how this came to be).  Since getenv() uses
the first one, Python should do too. (Some doubts about case
sensitivity, but for now this at least seems the right thing to do
regardless of platform.)

Modules/posixmodule.c

index f7b16a05ef928e46330dd164fad253c70b8b8f76..2a1efa63a909e219fb1effae4e66b62235f56f24 100644 (file)
@@ -300,7 +300,8 @@ convertenviron()
                if (v == NULL)
                        continue;
                *p = '\0';
-               (void) PyDict_SetItemString(d, *e, v);
+               if (PyDict_GetItemString(d, *e) == NULL)
+                       (void) PyDict_SetItemString(d, *e, v);
                *p = '=';
                Py_DECREF(v);
        }