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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2018-12-21 00:47:29 +00:00
Родитель 7d73acbbfb
Коммит 73f192f7fd
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -394,6 +394,11 @@ class TemplateFunction(object):
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

Просмотреть файл

@ -209,6 +209,7 @@ CONFIGS = defaultdict(lambda: {
'defines': {},
'non_global_defines': [],
'substs': {
'CC_TYPE': 'clang',
'COMPILE_ENVIRONMENT': '1',
'LIB_SUFFIX': 'a',
'BIN_SUFFIX': '.exe',