1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

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>
This commit is contained in:
Richard Purdie
2016-01-04 17:34:02 +00:00
parent b4141f6494
commit f5bfc1cc26
+4 -5
View File
@@ -292,7 +292,7 @@ def _print_trace(body, line):
error.append(' %.4d:%s' % (i, body[i-1].rstrip())) error.append(' %.4d:%s' % (i, body[i-1].rstrip()))
return error 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 A better compile method. This method
will print the offending lines. 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) cache = bb.methodpool.compile_cache(text)
if cache: if cache:
return cache return cache
code = compile(text, realfile, mode, ast.PyCF_ONLY_AST) # We can't add to the linenumbers for compile, we can pad to the correct number of blank lines though
if lineno is not None: text2 = "\n" * int(lineno) + text
ast.increment_lineno(code, lineno) code = compile(text2, realfile, mode)
code = compile(code, realfile, mode)
bb.methodpool.compile_cache_add(text, code) bb.methodpool.compile_cache_add(text, code)
return code return code
except Exception as e: except Exception as e: