public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [PATCH] lint: fix bad env dict handling
@ 2015-10-06  3:48 Mike Frysinger
  2015-10-06  6:27 ` Brian Dolbec
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2015-10-06  3:48 UTC (permalink / raw
  To: gentoo-catalyst

By using a kwarg default of {}, the value is retained across multiple
calls (and the linter warns about it).  Use the standard "if None"
style to avoid that.

Also fix the write to the dict passed in by creating a local copy
before we insert BASH_ENV into it.
---
 catalyst/support.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/catalyst/support.py b/catalyst/support.py
index b6705c9..78942a7 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -120,11 +120,14 @@ def find_binary(myc):
 	return None
 
 
-def cmd(mycmd, myexc="", env={}, debug=False, fail_func=None):
+def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
+	if env is None:
+		env = {}
 	#print "***** cmd()"
 	sys.stdout.flush()
 	args=[BASH_BINARY]
 	if "BASH_ENV" not in env:
+		env = env.copy()
 		env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
 	if debug:
 		args.append("-x")
-- 
2.5.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-catalyst] [PATCH] lint: fix bad env dict handling
  2015-10-06  3:48 [gentoo-catalyst] [PATCH] lint: fix bad env dict handling Mike Frysinger
@ 2015-10-06  6:27 ` Brian Dolbec
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2015-10-06  6:27 UTC (permalink / raw
  To: gentoo-catalyst

On Mon,  5 Oct 2015 23:48:02 -0400
Mike Frysinger <vapier@gentoo.org> wrote:

> By using a kwarg default of {}, the value is retained across multiple
> calls (and the linter warns about it).  Use the standard "if None"
> style to avoid that.
> 
> Also fix the write to the dict passed in by creating a local copy
> before we insert BASH_ENV into it.
> ---
>  catalyst/support.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/catalyst/support.py b/catalyst/support.py
> index b6705c9..78942a7 100644
> --- a/catalyst/support.py
> +++ b/catalyst/support.py
> @@ -120,11 +120,14 @@ def find_binary(myc):
>  	return None
>  
>  
> -def cmd(mycmd, myexc="", env={}, debug=False, fail_func=None):
> +def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
> +	if env is None:
> +		env = {}
>  	#print "***** cmd()"
>  	sys.stdout.flush()
>  	args=[BASH_BINARY]
>  	if "BASH_ENV" not in env:
> +		env = env.copy()
>  		env["BASH_ENV"] =
> "/etc/spork/is/not/valid/profile.env" if debug:
>  		args.append("-x")


How the hell did I miss that one, I've worked on this function a few
times.

Please merge :)
-- 
Brian Dolbec <dolsen>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-06  6:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-06  3:48 [gentoo-catalyst] [PATCH] lint: fix bad env dict handling Mike Frysinger
2015-10-06  6:27 ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox