From 893e2bb5b1ca48f59cca2ac4ebf78bfde253056a Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 11 Dec 2018 19:33:55 +0000 Subject: [PATCH] Bug 1513134 - Don't rely on ConfigureSandbox._imports for the lint. r=firefox-build-system-reviewers,gps _imports is cleared of functions at runtime, and that can cause the `func in self._imports` test to return False in cases where the function *does* have imports. Make the lint track which functions has imports on its own. This fortunately didn't cause mistakes not being caught by the lint in the current python configure code, but causes problems with upcoming changes. Depends on D14124 Differential Revision: https://phabricator.services.mozilla.com/D14125 --HG-- extra : moz-landing-system : lando --- python/mozbuild/mozbuild/configure/lint.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/configure/lint.py b/python/mozbuild/mozbuild/configure/lint.py index 71466e0e7d5d..84c69f4d61fe 100644 --- a/python/mozbuild/mozbuild/configure/lint.py +++ b/python/mozbuild/mozbuild/configure/lint.py @@ -31,6 +31,7 @@ class LintSandbox(ConfigureSandbox): environ = environ or {} argv = argv or [] self._wrapped = {} + self._has_imports = set() self._bool_options = [] self._bool_func_options = [] self.LOG = "" @@ -93,7 +94,7 @@ class LintSandbox(ConfigureSandbox): # - don't use @imports # - don't have a closure # - don't use global variables - if func in self._imports or func.func_closure: + if func in self._has_imports or func.func_closure: return True for op, arg in disassemble_as_iter(func): if op in ('LOAD_GLOBAL', 'STORE_GLOBAL'): @@ -208,3 +209,10 @@ class LintSandbox(ConfigureSandbox): self._wrapped[wrapper] = func return wraps(func)(wrapper) return do_wraps + + def imports_impl(self, _import, _from=None, _as=None): + wrapper = super(LintSandbox, self).imports_impl(_import, _from=_from, _as=_as) + def decorator(func): + self._has_imports.add(func) + return wrapper(func) + return decorator