зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
3ab0bd82c9
Коммит
893e2bb5b1
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче