Re: os.environ.copy()['COPY_HUH'] = "not really"

Under Python2.1 and earlier (back to 1.5.2):
import os os.environ.copy()['COPY_HUH'] = "not really" print os.environ['COPY_HUH'] not really
Under even 2.3a0 (CVS):
import os os.environ.copy()['COPY_HUH'] = "not really" os.system("echo $COPY_HUH") not really 0
Here's the problem:
print os.environ.__class__ os._Environ copy = os.environ.copy() print copy.__class__ os._Environ
It's not a real dictionary, but an os._Environ class. Copying it creates instances of the same class, and that class' behavior is to insert the item in the environment. I belive this should be avoided in this case, returning a true dictionary from copy(). I'll send a patch to SourceForge, if you haven't done so yet. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]
participants (1)
-
Gustavo Niemeyer