[issue15373] copy.copy() does not properly copy os.environment

2022-03-01 Thread Eryk Sun
Eryk Sun added the comment: In bpo-28824, I suggested preserving the case of environment variables in Windows by using a case-insensitive subclass of str in the encodekey() function. This is self-contained by the use of the encodekey() and decodekey() functions in the mapping methods such

[issue15373] copy.copy() does not properly copy os.environment

2022-03-01 Thread Max Katsev
Max Katsev added the comment: Note that deepcopy doesn't work either, even though it looks like it does at the first glance (which is arguably worse since it's harder to notice): Python 3.8.6 (default, Jun 4 2021, 05:16:01) >>> import copy, os, subprocess >>> env_copy =

[issue15373] copy.copy() does not properly copy os.environment

2021-09-21 Thread Andrei Kulakov
Andrei Kulakov added the comment: I guess the easy way to test it would be to modify the copy and check os.environ, but still there would be some uncertainty if it's consistent across platforms and python versions, if it's expected to still work in future python versions, etc. asdict()

[issue15373] copy.copy() does not properly copy os.environment

2021-09-21 Thread Anton Barkovsky
Change by Anton Barkovsky : -- nosy: -anton.barkovsky ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue15373] copy.copy() does not properly copy os.environment

2021-09-21 Thread Andrei Kulakov
Andrei Kulakov added the comment: I think the advantage of asdict() method is it's more discoverable and it doesn't leave any uncertainty of whether returned value will update environment or not. If a user sees `dict(os.environ)` in code, they may wonder if it does or does not; and there's

[issue15373] copy.copy() does not properly copy os.environment

2021-08-18 Thread Ryan Mast (nightlark)
Change by Ryan Mast (nightlark) : -- nosy: +rmast ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue15373] copy.copy() does not properly copy os.environment

2021-08-16 Thread Stéphane Blondon
Stéphane Blondon added the comment: I think an asdict() method is not necessary. Instanciating a dict from os.environ is enough: >>> import os >>> os.environ environ({'SHELL': '/bin/bash', ...}) >>> dict(os.environ) {'SHELL': '/bin/bash', ...}) With 'dict()', it's obvious there is no side

[issue15373] copy.copy() does not properly copy os.environment

2021-07-03 Thread Andrei Kulakov
Andrei Kulakov added the comment: I think it may be good to deprecate and discourage use of `os.environ.copy()`, and add a new method `os.environ.asdict()`. And possibly have `__copy__` raise an error pointing users to `os.environ.asdict()`. I'm not sure what to do about pickling.

[issue15373] copy.copy() does not properly copy os.environment

2021-03-13 Thread Kamil Turek
Change by Kamil Turek : -- nosy: +kamilturek ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue15373] copy.copy() does not properly copy os.environment

2021-01-12 Thread Josh Rosenberg
Josh Rosenberg added the comment: Would we remove the functionality of os.environ.copy()? It seems very odd for types to have a .copy() method that works, while not supporting copy.copy, especially when there is zero documentation, on the web or the docstring, to even hint at the

[issue15373] copy.copy() does not properly copy os.environment

2021-01-12 Thread Irit Katriel
Change by Irit Katriel : -- components: +Library (Lib) versions: +Python 3.10 -Python 3.7 ___ Python tracker ___ ___

[issue15373] copy.copy() does not properly copy os.environment

2017-01-31 Thread INADA Naoki
INADA Naoki added the comment: I agree. os.environ is not dict, it's a proxy of "current" environment which is not copyable. So I agree to copy.copy() shouldn't copy os.environ implicitly. -- ___ Python tracker

[issue15373] copy.copy() does not properly copy os.environment

2017-01-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: That patch would be fine except that I really agree with Antoine that an error should be raised. -- ___ Python tracker

[issue15373] copy.copy() does not properly copy os.environment

2017-01-29 Thread INADA Naoki
INADA Naoki added the comment: patch looks OK. But I prefer `__deepcopy__ = __copy__ = copy`. I don't know how to support pickling. (should unpickled object reference os.environ, or copied dict?) I feel it is different issue. -- nosy: +inada.naoki

[issue15373] copy.copy() does not properly copy os.environment

2017-01-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Antoine] > I agree with David that copy(os.environ) is rather ambiguous. > I think the preferred idiom should be to call dict(os.environ). > As for __copy__, I don't know what it should do: perhaps > simply raise an error when copying is attempted? FWIW, I

[issue15373] copy.copy() does not properly copy os.environment

2017-01-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If add support for the copy protocol, consider also adding support for deepcopying and pickling. -- nosy: +serhiy.storchaka ___ Python tracker

[issue15373] copy.copy() does not properly copy os.environment

2017-01-27 Thread Gregory P. Smith
Changes by Gregory P. Smith : -- keywords: +needs review nosy: +gregory.p.smith stage: -> patch review versions: +Python 3.7 -Python 3.4 ___ Python tracker

[issue15373] copy.copy() does not properly copy os.environment

2012-07-17 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I agree with David that copy(os.environ) is rather ambiguous. I think the preferred idiom should be to call dict(os.environ). As for __copy__, I don't know what it should do: perhaps simply raise an error when copying is attempted? --

[issue15373] copy.copy() does not properly copy os.environment

2012-07-17 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Well, I think the fact that os.environ.copy is explicitly supported (and does indeed do dict(os.environ)) is an argument in favor of giving that same meaning to copy(os.environ). I think that follows the principle of least surprise.

[issue15373] copy.copy() does not properly copy os.environment

2012-07-16 Thread Hartmut Goebel
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

[issue15373] copy.copy() does not properly copy os.environment

2012-07-16 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: os.environ is not a dictionary, so it isn't all that surprising that a shallow copy doesn't behave like a shallow copy of a dictionary. deepcopy does what you'd expect, as does os.environ.copy(). Perhaps it is worth improving this by

[issue15373] copy.copy() does not properly copy os.environment

2012-07-16 Thread Anton Barkovsky
Anton Barkovsky swarmer...@gmail.com added the comment: Here's a patch. -- keywords: +patch nosy: +anton.barkovsky Added file: http://bugs.python.org/file26403/environcopy.patch ___ Python tracker rep...@bugs.python.org

[issue15373] copy.copy() does not properly copy os.environment

2012-07-16 Thread Anton Barkovsky
Anton Barkovsky swarmer...@gmail.com added the comment: A new patch with tests. -- Added file: http://bugs.python.org/file26404/environcopy_v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15373