Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: components/policy/tools/syntax_check_policy_template_json.py

Issue 257583005: Fix crashes in components/policy/resources/PRESUBMIT.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@policy-list-doc
Patch Set: Move try/catch as suggested. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/resources/PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/tools/syntax_check_policy_template_json.py
diff --git a/components/policy/tools/syntax_check_policy_template_json.py b/components/policy/tools/syntax_check_policy_template_json.py
index 8d9edf3a1490ee5c2dd15112566c168163ad815e..a6a2302cea7aa99d377354891820e48fb0711e54 100755
--- a/components/policy/tools/syntax_check_policy_template_json.py
+++ b/components/policy/tools/syntax_check_policy_template_json.py
@@ -102,7 +102,11 @@ class PolicyTemplateChecker(object):
Returns: |container[key]| if the key is present, None otherwise.
'''
if identifier is None:
- identifier = container.get('name')
+ try:
+ identifier = container.get('name')
+ except:
+ self._Error('Cannot access container name of "%s".' % container_name)
+ return None
if container_name is None:
container_name = parent_element
if offending == '__CONTAINER__':
@@ -436,11 +440,11 @@ class PolicyTemplateChecker(object):
except:
import traceback
traceback.print_exc(file=sys.stdout)
- self._Error('Invalid JSON syntax.')
- return
+ self._Error('Invalid Python/JSON syntax.')
+ return 1
if data == None:
- self._Error('Invalid JSON syntax.')
- return
+ self._Error('Invalid Python/JSON syntax.')
+ return 1
self.options = options
# First part: check JSON structure.
« no previous file with comments | « components/policy/resources/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698