Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, Brian Dolbec <dolsen@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] portage.process.spawn: inherit env by default (bug 672440)
Date: Tue, 04 Dec 2018 01:39:52
Message-Id: 649c6779-463b-ff17-2f64-77b65fb5764c@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] portage.process.spawn: inherit env by default (bug 672440) by Brian Dolbec
1 On 12/3/18 8:49 AM, Brian Dolbec wrote:
2 > On Sun, 2 Dec 2018 23:55:23 -0800
3 > Zac Medico <zmedico@g.o> wrote:
4 >
5 >> Make child processes inherit the current process's environment by
6 >> default, so that behavior is equivalent to the standard library's
7 >> subprocess module.
8 >>
9 >> Bug: https://bugs.gentoo.org/672440
10 >> Signed-off-by: Zac Medico <zmedico@g.o>
11 >> ---
12 >> lib/portage/process.py | 10 +++++++---
13 >> 1 file changed, 7 insertions(+), 3 deletions(-)
14 >>
15 >> diff --git a/lib/portage/process.py b/lib/portage/process.py
16 >> index ed1a49247..ce3e42a8f 100644
17 >> --- a/lib/portage/process.py
18 >> +++ b/lib/portage/process.py
19 >> @@ -219,7 +219,7 @@ spawned_pids = _dummy_list()
20 >> def cleanup():
21 >> pass
22 >>
23 >> -def spawn(mycommand, env={}, opt_name=None, fd_pipes=None,
24 >> returnpid=False, +def spawn(mycommand, env=None, opt_name=None,
25 >> fd_pipes=None, returnpid=False, uid=None, gid=None, groups=None,
26 >> umask=None, cwd=None, logfile=None, path_lookup=True, pre_exec=None,
27 >> close_fds=(sys.version_info < (3, 4)), unshare_net=False,
28 >> @@ -230,8 +230,10 @@ def spawn(mycommand, env={}, opt_name=None,
29 >> fd_pipes=None, returnpid=False,
30 >> @param mycommand: the command to execute
31 >> @type mycommand: String or List (Popen style list)
32 >> - @param env: A dict of Key=Value pairs for env variables
33 >> - @type env: Dictionary
34 >> + @param env: If env is not None, it must be a mapping that
35 >> defines the environment
36 >> + variables for the new process; these are used
37 >> instead of the default behavior
38 >> + of inheriting the current process's environment.
39 >> + @type env: None or Mapping
40 >> @param opt_name: an optional name for the spawn'd process
41 >> (defaults to the binary name) @type opt_name: String
42 >> @param fd_pipes: A dict of mapping for pipes, { '0': stdin,
43 >> '1': stdout } for example @@ -281,6 +283,8 @@ def spawn(mycommand,
44 >> env={}, opt_name=None, fd_pipes=None, returnpid=False, if
45 >> isinstance(mycommand, basestring): mycommand = mycommand.split()
46 >>
47 >> + env = os.environ if env is None else env
48 >> +
49 >> if sys.hexversion < 0x3000000:
50 >> # Avoid a potential UnicodeEncodeError from
51 >> os.execve(). env_bytes = {}
52 >
53 >
54 > LGTM
55 >
56
57 Thanks, merged:
58
59 https://gitweb.gentoo.org/proj/portage.git/commit/?id=e9810a30bf044d93c0348d46225ad6b2ae1a45df
60 --
61 Thanks,
62 Zac

Attachments

File name MIME type
signature.asc application/pgp-signature