Fix try/except HAS_ logic

reviewable/pr18001/r1
Matt Martz 10 years ago committed by John Barker
parent b608194e59
commit 7a8862975e

@ -93,11 +93,12 @@ class ModuleValidator(object):
found_has = False found_has = False
if isinstance(child, ast.TryExcept): if isinstance(child, ast.TryExcept):
bodies = child.body bodies = child.body
bodies.extend([h.body for h in child.handlers]) for handler in child.handlers:
bodies.extend(handler.body)
for grandchild in bodies: for grandchild in bodies:
if isinstance(grandchild, ast.Import): if isinstance(grandchild, ast.Import):
found_try_except_import = True found_try_except_import = True
elif isinstance(grandchild, ast.Assign): if isinstance(grandchild, ast.Assign):
for target in grandchild.targets: for target in grandchild.targets:
if target.id.lower().startswith('has_'): if target.id.lower().startswith('has_'):
found_has = True found_has = True

Loading…
Cancel
Save