Issue 1181: Redefine clear() for os.environ to use unsetenv() if possible (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/45522

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 2022-04-11 14:56 by admin. 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) (Python triager) 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
2022-04-11 14:56:27 admin set github: 45522
2007-09-20 17:59:03 georg.brandl set status: open -> closedassignee: georg.brandlresolution: acceptedmessages: + nosy: + georg.brandl
2007-09-20 17:52:17 gvanrossum set messages: +
2007-09-20 17:46:04 draghuram set messages: +
2007-09-20 17:20:11 gvanrossum set nosy: + gvanrossummessages: +
2007-09-20 14:13:49 draghuram set nosy: + draghuram
2007-09-19 21:44:16 jafo set priority: normalkeywords: + patch
2007-09-19 21:38:22 martin.horcicka create