[New-bugs-announce] [issue5837] support.EnvironmentVarGuard broken

Walter Dörwald <report@bugs.python.org> at psf.upfronthosting.co.za Walter Dörwald <report@bugs.python.org> at psf.upfronthosting.co.za
Sat Apr 25 13:07:12 CEST 2009


New submission from Walter Dörwald <walter at livinglogic.de>:

support.EnvironmentVarGuard seems to be broken:

import os
from test import support

print(os.environ.get("HOME"))

with support.EnvironmentVarGuard() as env:
   env.unset("HOME")
   env.set("HOME", "foo")

print(os.environ.get("HOME"))

The output I get is:
   /Users/walter
   None

However I would have expected:
   /Users/walter
   /Users/walter

One solution would be to simply copy the exiting environment dictionary
in __enter__(), which would have the added advantage that code in the
with block could manipulate os.environ directly without going through
the EnvironmentGuardVariable.

----------
components: Tests
keywords: easy
messages: 86465
nosy: doerwalter
priority: low
severity: normal
stage: needs patch
status: open
title: support.EnvironmentVarGuard broken
type: behavior
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5837>
_______________________________________


More information about the New-bugs-announce mailing list