From b809a6812aa15a8a9af97bc382cc4b19571e6bfc Mon Sep 17 00:00:00 2001 From: Frazer Clews Date: Thu, 16 Jan 2020 17:11:19 +0000 Subject: lib: amend code to use proper singleton comparisons where possible amend the code to handle singleton comparisons properly so it only checks if they only refer to the same object or not, and not bother comparing the values. Signed-off-by: Frazer Clews Signed-off-by: Richard Purdie --- lib/bb/parse/ast.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/bb/parse') diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py index 362c1a39c..eb8cfa21b 100644 --- a/lib/bb/parse/ast.py +++ b/lib/bb/parse/ast.py @@ -89,7 +89,7 @@ class DataNode(AstNode): self.groupd = groupd def getFunc(self, key, data): - if 'flag' in self.groupd and self.groupd['flag'] != None: + if 'flag' in self.groupd and self.groupd['flag'] is not None: return data.getVarFlag(key, self.groupd['flag'], expand=False, noweakdefault=True) else: return data.getVar(key, False, noweakdefault=True, parsing=True) @@ -102,36 +102,36 @@ class DataNode(AstNode): 'file': self.filename, 'line': self.lineno, } - if "exp" in groupd and groupd["exp"] != None: + if "exp" in groupd and groupd["exp"] is not None: data.setVarFlag(key, "export", 1, op = 'exported', **loginfo) op = "set" - if "ques" in groupd and groupd["ques"] != None: + if "ques" in groupd and groupd["ques"] is not None: val = self.getFunc(key, data) op = "set?" - if val == None: + if val is None: val = groupd["value"] - elif "colon" in groupd and groupd["colon"] != None: + elif "colon" in groupd and groupd["colon"] is not None: e = data.createCopy() op = "immediate" val = e.expand(groupd["value"], key + "[:=]") - elif "append" in groupd and groupd["append"] != None: + elif "append" in groupd and groupd["append"] is not None: op = "append" val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"]) - elif "prepend" in groupd and groupd["prepend"] != None: + elif "prepend" in groupd and groupd["prepend"] is not None: op = "prepend" val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or "")) - elif "postdot" in groupd and groupd["postdot"] != None: + elif "postdot" in groupd and groupd["postdot"] is not None: op = "postdot" val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"]) - elif "predot" in groupd and groupd["predot"] != None: + elif "predot" in groupd and groupd["predot"] is not None: op = "predot" val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or "")) else: val = groupd["value"] flag = None - if 'flag' in groupd and groupd['flag'] != None: + if 'flag' in groupd and groupd['flag'] is not None: flag = groupd['flag'] elif groupd["lazyques"]: flag = "_defaultval" -- cgit 1.2.3-korg