Author htgoebel
Recipients htgoebel
Date 2012-07-16.16:08:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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/", 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.
Date User Action Args
2012-07-16 16:08:58htgoebelsetrecipients: + htgoebel
2012-07-16 16:08:57htgoebelsetmessageid: <>
2012-07-16 16:08:57htgoebellinkissue15373 messages
2012-07-16 16:08:56htgoebelcreate