[Patches] (no subject)

Fred Gansevles gansevle@cs.utwente.nl
Tue, 04 Apr 2000 16:51:07 +0200


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.

----------------------------------------------------------------
I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part

of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.
FAQ about legal
I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.

----------------------------------------------------------------
Index: os.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/os.py,v
retrieving revision 1.30
diff -c -r1.30 os.py
*** os.py	2000/02/04 15:39:30	1.30
--- os.py	2000/04/04 14:34:35
***************
*** 220,227 ****
          envpath = env['PATH']
      else:
          envpath = defpath
!     import string
!     PATH = string.splitfields(envpath, pathsep)
      if not _notfound:
          import tempfile
          # Exec a file that is guaranteed not to exist
--- 220,226 ----
          envpath = env['PATH']
      else:
          envpath = defpath
!     PATH = envpath.split (pathsep)
      if not _notfound:
          import tempfile
          # Exec a file that is guaranteed not to exist
***************
*** 248,269 ****
  
      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
              def __setitem__(self, key, item):
                  putenv(key, item)
!                 key = string.upper(key)
!                 self.data[key] = item
              def __getitem__(self, key):
!                 return self.data[string.upper(key)]
              def has_key(self, key):
!                 return self.data.has_key(string.upper(key))
  
      else:  # Where Env Var Names Can Be Mixed Case
          class _Environ(UserDict.UserDict):
--- 247,272 ----
  
      if name in ('os2', 'nt', 'dos'):  # Where Env Var Names Must Be UPPERCASE
          # But we store them as upper case
          class _Environ(UserDict.UserDict):
              def __init__(self, environ):
                  UserDict.UserDict.__init__(self)
                  data = self.data
                  for k, v in environ.items():
!                     data[k.upper()] = v
              def __setitem__(self, key, item):
                  putenv(key, item)
!                 self.data[key.upper()] = item
              def __getitem__(self, 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(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,278 ****
--- 276,284 ----
              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)