Make presubmit scripts not inherit the executor script's context

This caused compatibility issues, because the executor script (presubmit_support.py) asks the parser for Python 3-style print functions and inherits this to the presubmit scripts it runs, of which some still use the old style statements.

Bug: 961783
Change-Id: I545d778991a53f484bce6c7e29089e0484dc19ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1605917
Auto-Submit: Raul Tambre <raul@tambre.ee>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
changes/17/1605917/3
Raul Tambre 6 years ago committed by Commit Bot
parent 6a9b00e433
commit 09e64b49ee

@ -1218,7 +1218,8 @@ class GetTryMastersExecuter(object):
"""
context = {}
try:
exec script_text in context
exec(compile(script_text, 'PRESUBMIT.py', 'exec', dont_inherit=True),
context)
except Exception, e:
raise PresubmitFailure('"%s" had an exception.\n%s'
% (presubmit_path, e))
@ -1249,7 +1250,8 @@ class GetPostUploadExecuter(object):
"""
context = {}
try:
exec script_text in context
exec(compile(script_text, 'PRESUBMIT.py', 'exec', dont_inherit=True),
context)
except Exception, e:
raise PresubmitFailure('"%s" had an exception.\n%s'
% (presubmit_path, e))
@ -1414,7 +1416,8 @@ class PresubmitExecuter(object):
output_api = OutputApi(self.committing)
context = {}
try:
exec script_text in context
exec(compile(script_text, 'PRESUBMIT.py', 'exec', dont_inherit=True),
context)
except Exception, e:
raise PresubmitFailure('"%s" had an exception.\n%s' % (presubmit_path, e))

Loading…
Cancel
Save