Skip to contentSkip to conversation

codeparser: Allow empty functions

PATCH New Richard Purdie 1 participant 1 message Jun 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 codeparser: Allow empty functions

The main parser and other code copes with empty python functions but the python codeparser does not. Fix this to avoid errors with code like:

python do_build () {
}

which currently results in the obtuse:
"Failure expanding variable do_build: IndexError: string index out of range"

[YOCTO #7829]

bitbake/lib/bb/codeparser.py +3 -0
index 2d3574c..82a3af4 100644
@@ -245,6 +245,9 @@ class PythonParser():
         self.unhandled_message = "while parsing %s, %s" % (name, self.unhandled_message)
 
     def parse_python(self, node):
+        if not node or not node.strip():
+            return
+
         h = hash(str(node))
 
         if h in codeparsercache.pythoncache: