summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/os.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/os.py b/Lib/os.py
index d974c59..51e8a67 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -121,3 +121,22 @@ if name == 'nt':
list.append(line[:-1])
line = f.readline()
return list
+
+
+# Change environ to automatically call putenv() if it exists
+try:
+ _putenv = putenv
+except NameError:
+ _putenv = None
+if _putenv:
+ import UserDict
+
+ class _Environ(UserDict.UserDict):
+ def __init__(self, environ):
+ UserDict.UserDict.__init__(self)
+ self.data = environ
+ def __setitem__(self, key, item):
+ putenv(key, item)
+ self.data[key] = item
+
+ environ = _Environ(environ)