Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine clear() for os.environ to use unsetenv() if possible #45522

Closed
martinhorcicka mannequin opened this issue Sep 19, 2007 · 5 comments
Closed

Redefine clear() for os.environ to use unsetenv() if possible #45522

martinhorcicka mannequin opened this issue Sep 19, 2007 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@martinhorcicka
Copy link
Mannequin

martinhorcicka mannequin commented Sep 19, 2007

BPO 1181
Nosy @gvanrossum, @birkenfeld
Files
  • os.py.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/birkenfeld'
    closed_at = <Date 2007-09-20.17:59:03.671>
    created_at = <Date 2007-09-19.21:38:22.549>
    labels = ['type-bug', 'library']
    title = 'Redefine clear() for os.environ to use unsetenv() if possible'
    updated_at = <Date 2007-09-20.17:59:03.669>
    user = 'https://bugs.python.org/martinhorcicka'

    bugs.python.org fields:

    activity = <Date 2007-09-20.17:59:03.669>
    actor = 'georg.brandl'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2007-09-20.17:59:03.671>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2007-09-19.21:38:22.549>
    creator = 'martin.horcicka'
    dependencies = []
    files = ['8451']
    hgrepos = []
    issue_num = 1181
    keywords = ['patch']
    message_count = 5.0
    messages = ['56048', '56060', '56061', '56063', '56064']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'georg.brandl', 'draghuram', 'martin.horcicka']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1181'
    versions = []

    @martinhorcicka
    Copy link
    Mannequin Author

    martinhorcicka mannequin commented Sep 19, 2007

    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).

    @martinhorcicka martinhorcicka mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 19, 2007
    @gvanrossum
    Copy link
    Member

    Sounds like a good idea. Anyone care to check it in?

    @draghuram
    Copy link
    Mannequin

    draghuram mannequin commented Sep 20, 2007

    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.

    @gvanrossum
    Copy link
    Member

    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...

    @birkenfeld
    Copy link
    Member

    Committed, incl. docs, as rev. 58221.

    @birkenfeld birkenfeld self-assigned this Sep 20, 2007
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants