Skip to content

Commit

Permalink
fix try
Browse files Browse the repository at this point in the history
  • Loading branch information
hh-h committed Nov 16, 2019
1 parent a0754eb commit 14b721a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fastjsonschema/draft04.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def generate_any_of(self):
for definition_item in self._definition['anyOf']:
# When we know it's passing (at least once), we do not need to do another expensive try-except.
with self.l('if not {variable}_any_of_count:', optimize=False):
with self.l('try:'):
with self.l('try:', optimize=False):
self.generate_func_code_block(definition_item, self._variable, self._variable_name, clear_variables=True)
self.l('{variable}_any_of_count += 1')
self.l('except JsonSchemaException: pass')
Expand Down Expand Up @@ -174,7 +174,7 @@ def generate_one_of(self):
for definition_item in self._definition['oneOf']:
# When we know it's failing (one of means exactly once), we do not need to do another expensive try-except.
with self.l('if {variable}_one_of_count < 2:', optimize=False):
with self.l('try:'):
with self.l('try:', optimize=False):
self.generate_func_code_block(definition_item, self._variable, self._variable_name, clear_variables=True)
self.l('{variable}_one_of_count += 1')
self.l('except JsonSchemaException: pass')
Expand Down Expand Up @@ -204,7 +204,7 @@ def generate_not(self):
with self.l('if {}:', self._variable):
self.exc('{name} must not be valid by not definition', rule='not')
else:
with self.l('try:'):
with self.l('try:', optimize=False):
self.generate_func_code_block(not_definition, self._variable, self._variable_name)
self.l('except JsonSchemaException: pass')
with self.l('else:'):
Expand Down Expand Up @@ -260,7 +260,7 @@ def generate_format(self):
self._generate_format(format_, format_ + '_re_pattern', format_regex)
# Format regex is used only in meta schemas.
elif format_ == 'regex':
with self.l('try:'):
with self.l('try:', optimize=False):
self.l('re.compile({variable})')
with self.l('except Exception:'):
self.exc('{name} must be a valid regex', rule='format')
Expand Down

0 comments on commit 14b721a

Please sign in to comment.