[Python-checkins] r58651 - in python/trunk: Doc/library/os.rst Lib/os.py Misc/NEWS

georg.brandl python-checkins at python.org
Wed Oct 24 23:40:39 CEST 2007


Author: georg.brandl
Date: Wed Oct 24 23:40:38 2007
New Revision: 58651

Modified:
   python/trunk/Doc/library/os.rst
   python/trunk/Lib/os.py
   python/trunk/Misc/NEWS
Log:
Bug #1287: make os.environ.pop() work as expected.


Modified: python/trunk/Doc/library/os.rst
==============================================================================
--- python/trunk/Doc/library/os.rst	(original)
+++ python/trunk/Doc/library/os.rst	Wed Oct 24 23:40:38 2007
@@ -118,10 +118,11 @@
    If the platform supports the :func:`unsetenv` function, you can delete items in
    this mapping to unset environment variables. :func:`unsetenv` will be called
    automatically when an item is deleted from ``os.environ``, and when
-   :meth:`os.environ.clear` is called.
+   one of the :meth:`pop` or :meth:`clear` methods is called.
 
    .. versionchanged:: 2.6
-      Also unset environment variables when calling :meth:`os.environ.clear`.
+      Also unset environment variables when calling :meth:`os.environ.clear`
+      and :meth:`os.environ.pop`.
 
 
 .. function:: chdir(path)

Modified: python/trunk/Lib/os.py
==============================================================================
--- python/trunk/Lib/os.py	(original)
+++ python/trunk/Lib/os.py	Wed Oct 24 23:40:38 2007
@@ -450,6 +450,9 @@
                     for key in self.data.keys():
                         unsetenv(key)
                         del self.data[key]
+                def pop(self, key, *args):
+                    unsetenv(key)
+                    return self.data.pop(key, *args)
             def has_key(self, key):
                 return key.upper() in self.data
             def __contains__(self, key):
@@ -511,6 +514,9 @@
                     for key in self.data.keys():
                         unsetenv(key)
                         del self.data[key]
+                def pop(self, key, *args):
+                    unsetenv(key)
+                    return self.data.pop(key, *args)
             def copy(self):
                 return dict(self)
 

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Oct 24 23:40:38 2007
@@ -274,11 +274,14 @@
 Library
 -------
 
+- Issues #1181, #1287: unsetenv() is now called when the os.environ.pop()
+  and os.environ.clear() methods are used.
+
 - ctypes will now work correctly on 32-bit systems when Python is
   configured with --with-system-ffi.
 
 - Patch #1203: ctypes now does work on OS X when Python is built with
-  --disable-toolbox-glue
+  --disable-toolbox-glue.
 
 - collections.deque() now supports a "maxlen" argument.
 


More information about the Python-checkins mailing list