From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9FE3F138334 for ; Tue, 4 Dec 2018 01:35:36 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7FE2CE0A59; Tue, 4 Dec 2018 01:35:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 57447E0A59 for ; Tue, 4 Dec 2018 01:35:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B4EF1335C07 for ; Tue, 4 Dec 2018 01:35:32 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1328744C for ; Tue, 4 Dec 2018 01:35:31 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1543886103.e9810a30bf044d93c0348d46225ad6b2ae1a45df.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/process.py X-VCS-Directories: lib/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: e9810a30bf044d93c0348d46225ad6b2ae1a45df X-VCS-Branch: master Date: Tue, 4 Dec 2018 01:35:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e99a6b08-7c89-4e2b-84ed-84791181a4f4 X-Archives-Hash: 0af890cdb3542fec07177ec804b6bba4 commit: e9810a30bf044d93c0348d46225ad6b2ae1a45df Author: Zac Medico gentoo org> AuthorDate: Mon Dec 3 07:47:32 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Dec 4 01:15:03 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e9810a30 portage.process.spawn: inherit env by default (bug 672440) Make child processes inherit the current process's environment by default, so that behavior is equivalent to the standard library's subprocess module. Bug: https://bugs.gentoo.org/672440 Reviewed-by: Brian Dolbec gentoo.org> Signed-off-by: Zac Medico gentoo.org> lib/portage/process.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/portage/process.py b/lib/portage/process.py index ed1a49247..ce3e42a8f 100644 --- a/lib/portage/process.py +++ b/lib/portage/process.py @@ -219,7 +219,7 @@ spawned_pids = _dummy_list() def cleanup(): pass -def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, +def spawn(mycommand, env=None, opt_name=None, fd_pipes=None, returnpid=False, uid=None, gid=None, groups=None, umask=None, cwd=None, logfile=None, path_lookup=True, pre_exec=None, close_fds=(sys.version_info < (3, 4)), unshare_net=False, @@ -230,8 +230,10 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, @param mycommand: the command to execute @type mycommand: String or List (Popen style list) - @param env: A dict of Key=Value pairs for env variables - @type env: Dictionary + @param env: If env is not None, it must be a mapping that defines the environment + variables for the new process; these are used instead of the default behavior + of inheriting the current process's environment. + @type env: None or Mapping @param opt_name: an optional name for the spawn'd process (defaults to the binary name) @type opt_name: String @param fd_pipes: A dict of mapping for pipes, { '0': stdin, '1': stdout } for example @@ -281,6 +283,8 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, if isinstance(mycommand, basestring): mycommand = mycommand.split() + env = os.environ if env is None else env + if sys.hexversion < 0x3000000: # Avoid a potential UnicodeEncodeError from os.execve(). env_bytes = {}