From 715d857174ceca82b85d6c8c7df520047ba7fb0c Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 17 Aug 2015 12:12:16 +0100 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'bitbake/lib/bb/cooker.py') 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 -- cgit v1.2.3-54-g00ecf