On 12/3/18 8:49 AM, Brian Dolbec wrote:
> On Sun,  2 Dec 2018 23:55:23 -0800
> Zac Medico <zmed...@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 <zmed...@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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to