diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-08-17 12:12:16 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-19 18:05:44 +0100 |
commit | 715d857174ceca82b85d6c8c7df520047ba7fb0c (patch) | |
tree | 363aac81a06b013471f1dede8ba4c0dc7d8bbe92 /bitbake/lib/bb/cooker.py | |
parent | 22a653d02880c35d3c9d04811c31aabdf1e69951 (diff) | |
download | openembedded-core-contrib-715d857174ceca82b85d6c8c7df520047ba7fb0c.tar.gz |
bitbake: Fix default function parameter assignment to a list
With python you should not assign a list as the default value of a
function parameter - because a list is mutable, the result will be that
the first time a value is passed it will actually modify the default.
Reference:
http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments
(Bitbake rev: 7859f7388f2e3f675d0e1527cfde18625f36f637)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 0f99342a0f..84bf46b9ee 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -114,12 +114,13 @@ class BBCooker: Manages one bitbake build run """ - def __init__(self, configuration, featureSet = []): + def __init__(self, configuration, featureSet=None): self.recipecache = None self.skiplist = {} self.featureset = CookerFeatures() - for f in featureSet: - self.featureset.setFeature(f) + if featureSet: + for f in featureSet: + self.featureset.setFeature(f) self.configuration = configuration @@ -567,12 +568,14 @@ class BBCooker: logger.plain("%-35s %25s %25s", p, lateststr, prefstr) - def showEnvironment(self, buildfile = None, pkgs_to_build = []): + def showEnvironment(self, buildfile=None, pkgs_to_build=None): """ Show the outer or per-recipe environment """ fn = None envdata = None + if not pkgs_to_build: + pkgs_to_build = [] if buildfile: # Parse the configuration here. We need to do it explicitly here since @@ -1037,13 +1040,13 @@ class BBCooker: return pkg_list - def generateTargetsTree(self, klass=None, pkgs=[]): + def generateTargetsTree(self, klass=None, pkgs=None): """ Generate a dependency tree of buildable targets Generate an event with the result """ # if the caller hasn't specified a pkgs list default to universe - if not len(pkgs): + if not pkgs: pkgs = ['universe'] # if inherited_class passed ensure all recipes which inherit the # specified class are included in pkgs |