New submission from Hartmut Goebel <h.goe...@crazy-compilers.com>: 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. ---------- messages: 165631 nosy: htgoebel priority: normal severity: normal status: open title: copy.copy() does not properly copy os.environment type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15373> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com