diff options
author | Guido van Rossum <guido@python.org> | 1996-07-24 00:55:17 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-07-24 00:55:17 (GMT) |
commit | 3b8e20d2c2022f49376578f230ea1cbb54f694f7 (patch) | |
tree | e02267c4343eb53a5ec688c7cae91bd863cef2a0 /Lib/os.py | |
parent | 4dc66220574d68a89a62cf64a5114b8fea877997 (diff) | |
download | cpython-3b8e20d2c2022f49376578f230ea1cbb54f694f7.zip cpython-3b8e20d2c2022f49376578f230ea1cbb54f694f7.tar.gz cpython-3b8e20d2c2022f49376578f230ea1cbb54f694f7.tar.bz2 |
Added hook to os.environ to call putenv(), if it exists.
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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) |