classification
Title: Redefine clear() for os.environ to use unsetenv() if possible
Type: behavior Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: draghuram, georg.brandl, gvanrossum, martin.horcicka
Priority: normal Keywords: patch

Created on 2007-09-19 21:38 by martin.horcicka, last changed 2007-09-20 17:59 by georg.brandl. This issue is now closed.

Files
File name Uploaded Description Edit
os.py.patch martin.horcicka, 2007-09-19 21:38
Messages (5)
msg56048 - (view) Author: Martin Horcicka (martin.horcicka) Date: 2007-09-19 21:38
This patch makes os.environ.clear() to have the same effect as:

for name in os.environ.keys():
    del os.environ[name]

I believe that most people expect the effects to be the same anyway.

The practical benefit is a simpler redefinition of the whole environment
if desired (e.g. in scripts run via sudo on unix systems).
msg56060 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-09-20 17:20
Sounds like a good idea. Anyone care to check it in?
msg56061 - (view) Author: Raghuram Devarakonda (draghuram) Date: 2007-09-20 17:46
Shouldn't the first clear() in the patch say "del
self.data[key.upper()]" instead of "del self.data[key]"? I also think
the patch should include doc change.
msg56063 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-09-20 17:52
On 9/20/07, Raghuram Devarakonda <report@bugs.python.org> wrote:
> Shouldn't the first clear() in the patch say "del
> self.data[key.upper()]" instead of "del self.data[key]"? I also think
> the patch should include doc change.

I don't think so -- it goes over self.data.keys() which means they are
already uppercase.

All of this would be unnecessary if clear() in UserDict were to be changed to

for key in self.keys(): del self[key]

But that's a much more pervasive change...
msg56064 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-20 17:59
Committed, incl. docs, as rev. 58221.
History
Date User Action Args
2007-09-20 17:59:03georg.brandlsetstatus: open -> closed
assignee: georg.brandl
resolution: accepted
messages: + msg56064
nosy: + georg.brandl
2007-09-20 17:52:17gvanrossumsetmessages: + msg56063
2007-09-20 17:46:04draghuramsetmessages: + msg56061
2007-09-20 17:20:11gvanrossumsetnosy: + gvanrossum
messages: + msg56060
2007-09-20 14:13:49draghuramsetnosy: + draghuram
2007-09-19 21:44:16jafosetpriority: normal
keywords: + patch
2007-09-19 21:38:22martin.horcickacreate