Commit ea7c855b authored by maruel@chromium.org's avatar maruel@chromium.org

Inhibit python subprocess from generating .pyc files anymore.

This would case a failure when:
- a .py file is moved
- *.pyc is in svn:ignore, causing the .pyc to not be deleted.
- the new .py modifies its API.
- another .py imports the old .py and uses the new API.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6854022

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81942 0039d316-1c4b-4281-b951-d872f2087c98
parent 0d5ef24c
......@@ -1035,14 +1035,20 @@ def DoPresubmitChecks(change,
A PresubmitOutput object. Use output.should_continue() to figure out
if there were errors or warnings and the caller should abort.
"""
old_environ = os.environ
try:
# Make sure python subprocesses won't generate .pyc files.
os.environ = os.environ.copy()
os.environ['PYTHONDONTWRITEBYTECODE'] = '1'
output = PresubmitOutput(input_stream, output_stream)
if committing:
output.write("Running presubmit commit checks ...\n")
else:
output.write("Running presubmit upload checks ...\n")
start_time = time.time()
presubmit_files = ListRelevantPresubmitFiles(change.AbsoluteLocalPaths(True),
change.RepositoryRoot())
presubmit_files = ListRelevantPresubmitFiles(
change.AbsoluteLocalPaths(True), change.RepositoryRoot())
if not presubmit_files and verbose:
output.write("Warning, no presubmit.py found.\n")
results = []
......@@ -1101,6 +1107,8 @@ def DoPresubmitChecks(change,
"& hate mail to maruel@chromium.org!\n")
_ASKED_FOR_FEEDBACK = True
return output
finally:
os.environ = old_environ
def ScanSubDirs(mask, recursive):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment