summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT.py
diff options
context:
space:
mode:
authorplundblad <plundblad@chromium.org>2015-07-23 04:31:13 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-23 11:32:02 +0000
commit1f5a4509f085ef3f7cf8f3f5110c2d9779401a1b (patch)
treec0ac8acd71fc180b4d74aee1592b4a2b3c02e214 /PRESUBMIT.py
parent85ad204e6d018ed1e61a8d57f0ef3ff51079cf75 (diff)
downloadchromium_src-1f5a4509f085ef3f7cf8f3f5110c2d9779401a1b.zip
chromium_src-1f5a4509f085ef3f7cf8f3f5110c2d9779401a1b.tar.gz
chromium_src-1f5a4509f085ef3f7cf8f3f5110c2d9779401a1b.tar.bz2
Fix encoding problem with json validation in PRESUBMIT.py.
The presubmit script was calling out to a subprocess to discard comments in json files. https://codereview.chromium.org/1253453002 exposed some encoding issue when sending the Unicode content back and forth. Rather than trying to figure out how to get that right, just import and use the json_comment_eater python module directly. BUG=513181 TESTED=git cl presubmit passed for the above-mentioned CL . Review URL: https://codereview.chromium.org/1248323002 Cr-Commit-Position: refs/heads/master@{#340071}
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r--PRESUBMIT.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index c926dd7..a888b11 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1198,15 +1198,16 @@ def _GetJSONParseError(input_api, filename, eat_comments=True):
try:
contents = input_api.ReadFile(filename)
if eat_comments:
- json_comment_eater = input_api.os_path.join(
- input_api.PresubmitLocalPath(),
- 'tools', 'json_comment_eater', 'json_comment_eater.py')
- process = input_api.subprocess.Popen(
- [input_api.python_executable, json_comment_eater],
- stdin=input_api.subprocess.PIPE,
- stdout=input_api.subprocess.PIPE,
- universal_newlines=True)
- (contents, _) = process.communicate(input=contents)
+ import sys
+ original_sys_path = sys.path
+ try:
+ sys.path = sys.path + [input_api.os_path.join(
+ input_api.PresubmitLocalPath(),
+ 'tools', 'json_comment_eater')]
+ import json_comment_eater
+ finally:
+ sys.path = original_sys_path
+ contents = json_comment_eater.Nom(contents)
input_api.json.loads(contents)
except ValueError as e: