A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-April/023847.html below:

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

[Python-Dev] Re: os.environ.copy()['COPY_HUH'] = "not really" [Python-Dev] Re: os.environ.copy()['COPY_HUH'] = "not really"Gustavo Niemeyer niemeyer@conectiva.com
Tue, 30 Apr 2002 18:30:53 -0300
> 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 ]




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4