aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/utils.py
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-05 14:08:07 +0000
commit10256ac3e7be7e691176ecc5d55856d88f1fe940 (patch)
tree5c96025a415c595941f58f56a07b108498eee298 /lib/bb/utils.py
parente130dca85bac82bd4d88f94a6bf9fe36e8ad4d7c (diff)
downloadbitbake-10256ac3e7be7e691176ecc5d55856d88f1fe940.tar.gz
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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r--lib/bb/utils.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index cd5fcede3..9a3efb25d 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -292,7 +292,7 @@ def _print_trace(body, line):
error.append(' %.4d:%s' % (i, body[i-1].rstrip()))
return error
-def better_compile(text, file, realfile, mode = "exec", lineno = None):
+def better_compile(text, file, realfile, mode = "exec", lineno = 0):
"""
A better compile method. This method
will print the offending lines.
@@ -301,10 +301,9 @@ def better_compile(text, file, realfile, mode = "exec", lineno = None):
cache = bb.methodpool.compile_cache(text)
if cache:
return cache
- code = compile(text, realfile, mode, ast.PyCF_ONLY_AST)
- if lineno is not None:
- ast.increment_lineno(code, lineno)
- code = compile(code, realfile, mode)
+ # We can't add to the linenumbers for compile, we can pad to the correct number of blank lines though
+ text2 = "\n" * int(lineno) + text
+ code = compile(text2, realfile, mode)
bb.methodpool.compile_cache_add(text, code)
return code
except Exception as e: