summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-04 17:34:02 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-06 15:27:34 +0000
commitf5bfc1cc26ddfb38121cc7d79869a86219dcf5c4 (patch)
tree8c432179515518282f3f7f19abb0e2d049fed8f6 /bitbake
parentb4141f6494bf529255e17eb0e9bdd9297ece99a3 (diff)
downloadpoky-f5bfc1cc26ddfb38121cc7d79869a86219dcf5c4.tar.gz
bitbake: utils: Remove double compile from better_compile
Poking around the ast to correct linenumbers works well for runtime failures but not for parsing ones. We can use blank linefeeds to correct the line numbers instead, with the advantage that we don't need to double compile. (Bitbake rev: 10256ac3e7be7e691176ecc5d55856d88f1fe940) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index cd5fcede3c..9a3efb25de 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -292,7 +292,7 @@ def _print_trace(body, line):
292 error.append(' %.4d:%s' % (i, body[i-1].rstrip())) 292 error.append(' %.4d:%s' % (i, body[i-1].rstrip()))
293 return error 293 return error
294 294
295def better_compile(text, file, realfile, mode = "exec", lineno = None): 295def better_compile(text, file, realfile, mode = "exec", lineno = 0):
296 """ 296 """
297 A better compile method. This method 297 A better compile method. This method
298 will print the offending lines. 298 will print the offending lines.
@@ -301,10 +301,9 @@ def better_compile(text, file, realfile, mode = "exec", lineno = None):
301 cache = bb.methodpool.compile_cache(text) 301 cache = bb.methodpool.compile_cache(text)
302 if cache: 302 if cache:
303 return cache 303 return cache
304 code = compile(text, realfile, mode, ast.PyCF_ONLY_AST) 304 # We can't add to the linenumbers for compile, we can pad to the correct number of blank lines though
305 if lineno is not None: 305 text2 = "\n" * int(lineno) + text
306 ast.increment_lineno(code, lineno) 306 code = compile(text2, realfile, mode)
307 code = compile(code, realfile, mode)
308 bb.methodpool.compile_cache_add(text, code) 307 bb.methodpool.compile_cache_add(text, code)
309 return code 308 return code
310 except Exception as e: 309 except Exception as e: