[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-portage-dev
Subject:    Re: [gentoo-portage-dev] [PATCH] portage.process.spawn: inherit env by default (bug 672440)
From:       Zac Medico <zmedico () gentoo ! org>
Date:       2018-12-04 1:39:47
Message-ID: 649c6779-463b-ff17-2f64-77b65fb5764c () gentoo ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


On 12/3/18 8:49 AM, Brian Dolbec wrote:
> On Sun,  2 Dec 2018 23:55:23 -0800
> Zac Medico <zmedico@gentoo.org> wrote:
> 
>> 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
>> Signed-off-by: Zac Medico <zmedico@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 = {}
> 
> 
> LGTM
> 

Thanks, merged:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=e9810a30bf044d93c0348d46225ad6b2ae1a45df
-- 
Thanks,
Zac


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic