Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH] lint: fix bad env dict handling
Date: Tue, 06 Oct 2015 06:27:56
Message-Id: 20151005232703.613ac61e.dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH] lint: fix bad env dict handling by Mike Frysinger
1 On Mon, 5 Oct 2015 23:48:02 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > By using a kwarg default of {}, the value is retained across multiple
5 > calls (and the linter warns about it). Use the standard "if None"
6 > style to avoid that.
7 >
8 > Also fix the write to the dict passed in by creating a local copy
9 > before we insert BASH_ENV into it.
10 > ---
11 > catalyst/support.py | 5 ++++-
12 > 1 file changed, 4 insertions(+), 1 deletion(-)
13 >
14 > diff --git a/catalyst/support.py b/catalyst/support.py
15 > index b6705c9..78942a7 100644
16 > --- a/catalyst/support.py
17 > +++ b/catalyst/support.py
18 > @@ -120,11 +120,14 @@ def find_binary(myc):
19 > return None
20 >
21 >
22 > -def cmd(mycmd, myexc="", env={}, debug=False, fail_func=None):
23 > +def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
24 > + if env is None:
25 > + env = {}
26 > #print "***** cmd()"
27 > sys.stdout.flush()
28 > args=[BASH_BINARY]
29 > if "BASH_ENV" not in env:
30 > + env = env.copy()
31 > env["BASH_ENV"] =
32 > "/etc/spork/is/not/valid/profile.env" if debug:
33 > args.append("-x")
34
35
36 How the hell did I miss that one, I've worked on this function a few
37 times.
38
39 Please merge :)
40 --
41 Brian Dolbec <dolsen>