diff options
author | Georg Brandl <georg@python.org> | 2007-10-24 21:40:38 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-10-24 21:40:38 (GMT) |
commit | 1a94ec266483cf3212e362cb20ffb989e254ecf3 (patch) | |
tree | 47a318c659f0183114d2312c5f1ee746f7a73c44 | |
parent | 9afb9850f28519879fdadaa9467a7bdb46b01417 (diff) | |
download | cpython-1a94ec266483cf3212e362cb20ffb989e254ecf3.zip cpython-1a94ec266483cf3212e362cb20ffb989e254ecf3.tar.gz cpython-1a94ec266483cf3212e362cb20ffb989e254ecf3.tar.bz2 |
Bug #1287: make os.environ.pop() work as expected.
-rw-r--r-- | Doc/library/os.rst | 5 | ||||
-rw-r--r-- | Lib/os.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 5 |
3 files changed, 13 insertions, 3 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index bc4cf42..0e46741 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -118,10 +118,11 @@ process and user. 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) @@ -450,6 +450,9 @@ else: 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 @@ else: 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) @@ -274,11 +274,14 @@ Core and builtins 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. |