summaryrefslogtreecommitdiff
path: root/Lib/os.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-04-04 19:50:04 +0000
committerGuido van Rossum <guido@python.org>2000-04-04 19:50:04 +0000
commit965fdae40ea976fa133048110b24f35cc829b3c8 (patch)
treec1d8f9fc6fc1017d1c3e408bca84d60304df5e3b /Lib/os.py
parent56a87a090558ea69a9857d05c3dcf286801bbd7a (diff)
downloadcpython-git-965fdae40ea976fa133048110b24f35cc829b3c8.tar.gz
Patch by Fred Gansevles.
This patch solves 2 problems of the os module. 1) Bug ID #50 (case-mismatch wiht "environ.get(..,..)" and "del environ[..]") 2) os.environ.update (dict) doesn't propagate changes to the 'real' environment (i.e doesn't call putenv) This patches also has minor changes specific for 1.6a The string module isn't used anymore, instead the strings own methods are used.
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 118b6198bf..eed95c5d22 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -220,8 +220,7 @@ def _execvpe(file, args, env=None):
envpath = env['PATH']
else:
envpath = defpath
- import string
- PATH = string.splitfields(envpath, pathsep)
+ PATH = envpath.split(pathsep)
if not _notfound:
import tempfile
# Exec a file that is guaranteed not to exist
@@ -248,22 +247,26 @@ else:
if name in ('os2', 'nt', 'dos'): # Where Env Var Names Must Be UPPERCASE
# But we store them as upper case
- import string
class _Environ(UserDict.UserDict):
def __init__(self, environ):
UserDict.UserDict.__init__(self)
data = self.data
- upper = string.upper
for k, v in environ.items():
- data[upper(k)] = v
+ data[k.upper()] = v
def __setitem__(self, key, item):
putenv(key, item)
- key = string.upper(key)
- self.data[key] = item
+ self.data[key.upper()] = item
def __getitem__(self, key):
- return self.data[string.upper(key)]
+ return self.data[key.upper()]
+ def __delitem__(self, key):
+ del self.data[key.upper()]
def has_key(self, key):
- return self.data.has_key(string.upper(key))
+ return self.data.has_key(key.upper())
+ def get(self, key, failobj=None):
+ return self.data.get(key.upper(), failobj)
+ def update(self, dict):
+ for k, v in dict.items():
+ self[k] = v
else: # Where Env Var Names Can Be Mixed Case
class _Environ(UserDict.UserDict):
@@ -273,6 +276,9 @@ else:
def __setitem__(self, key, item):
putenv(key, item)
self.data[key] = item
+ def update(self, dict):
+ for k, v in dict.items():
+ self[k] = v
environ = _Environ(environ)