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

Unified Diff: components/policy/resources/PRESUBMIT.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: 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 | « no previous file | components/policy/tools/syntax_check_policy_template_json.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/resources/PRESUBMIT.py
diff --git a/components/policy/resources/PRESUBMIT.py b/components/policy/resources/PRESUBMIT.py
index 3870875aa379667a0dc5c6d59e95347b8e3934b3..19ea0ec12606960f27f1f513864f564e8b6e41e1 100644
--- a/components/policy/resources/PRESUBMIT.py
+++ b/components/policy/resources/PRESUBMIT.py
@@ -16,14 +16,17 @@ def _GetPolicyTemplates(template_path):
# is actually maintained as a python dictionary.
with open(template_path) as f:
template_data = eval(f.read(), {})
- policies = ( policy
+ try:
+ policies = ( policy
+ for policy in template_data['policy_definitions']
+ if policy['type'] != 'group' )
+ groups = ( policy['policies']
for policy in template_data['policy_definitions']
- if policy['type'] != 'group' )
- groups = ( policy['policies']
- for policy in template_data['policy_definitions']
- if policy['type'] == 'group' )
- subpolicies = ( policy for group in groups for policy in group )
- return list(itertools.chain(policies, subpolicies))
+ if policy['type'] == 'group' )
+ subpolicies = ( policy for group in groups for policy in group )
+ return list(itertools.chain(policies, subpolicies))
+ except:
+ return list()
def _CheckPolicyTemplatesSyntax(input_api, output_api):
local_path = input_api.PresubmitLocalPath()
« no previous file with comments | « no previous file | components/policy/tools/syntax_check_policy_template_json.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698