Bug 1515808 - Compensate for older python's buggy inspect.getblock. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 21 Dec 2018 00:47:29 +0000
changeset 511592 75572e56c170
parent 511591 e1bac09e54c6
child 511593 3aee5a63d544
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1515808
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1515808 - Compensate for older python's buggy inspect.getblock. r=nalexander Fixing this unveils an issue in TestRecursiveMake::test_linkage that was happening locally but not on automation, due to the Binary() template never being invoked on automation. Differential Revision: https://phabricator.services.mozilla.com/D15162
python/mozbuild/mozbuild/frontend/reader.py
python/mozbuild/mozbuild/test/backend/common.py
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -389,16 +389,21 @@ class MozbuildSandbox(Sandbox):
 class TemplateFunction(object):
     def __init__(self, func, sandbox):
         self.path = func.func_code.co_filename
         self.name = func.func_name
 
         code = func.func_code
         firstlineno = code.co_firstlineno
         lines = sandbox._current_source.splitlines(True)
+        if lines:
+            # Older versions of python 2.7 had a buggy inspect.getblock() that
+            # would ignore the last line if it didn't terminate with a newline.
+            if not lines[-1].endswith('\n'):
+                lines[-1] += '\n'
         lines = inspect.getblock(lines[firstlineno - 1:])
 
         # The code lines we get out of inspect.getsourcelines look like
         #   @template
         #   def Template(*args, **kwargs):
         #       VAR = 'value'
         #       ...
         func_ast = ast.parse(''.join(lines), self.path)
--- a/python/mozbuild/mozbuild/test/backend/common.py
+++ b/python/mozbuild/mozbuild/test/backend/common.py
@@ -204,16 +204,17 @@ CONFIGS = defaultdict(lambda: {
             'COMPILE_ENVIRONMENT': '1',
             'BIN_SUFFIX': '.prog',
         },
     },
     'linkage': {
         'defines': {},
         'non_global_defines': [],
         'substs': {
+            'CC_TYPE': 'clang',
             'COMPILE_ENVIRONMENT': '1',
             'LIB_SUFFIX': 'a',
             'BIN_SUFFIX': '.exe',
             'DLL_SUFFIX': '.so',
             'OBJ_SUFFIX': 'o',
             'EXPAND_LIBS_LIST_STYLE': 'list',
         },
     },