This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author htgoebel
Recipients htgoebel
Date 2012-07-16.16:08:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342454937.95.0.386630033182.issue15373@psf.upfronthosting.co.za>
In-reply-to
Content
Wehn copying os.environ usinf copy.copy(), any manipulation on the copied object will change os.environment, too.

$ python
Python 2.7.3 (default, Apr 22 2012, 07:46:58) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import copy, os
>>> os.environ['TITI']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'TITI'
>>> env = copy.copy(os.environ)
>>> env['TITI'] = 'in den Ferien'
>>> os.environ['TITI']
'in den Ferien'
>>> 

Strictly speaking, this is correct, as the os.environment class is meant to manipulate the environment in the background. But user's expectation is different: he thinks, manipulating the copied object is save and does not effect the environment.
History
Date User Action Args
2012-07-16 16:08:58htgoebelsetrecipients: + htgoebel
2012-07-16 16:08:57htgoebelsetmessageid: <1342454937.95.0.386630033182.issue15373@psf.upfronthosting.co.za>
2012-07-16 16:08:57htgoebellinkissue15373 messages
2012-07-16 16:08:56htgoebelcreate