Fix try/except HAS_ logic

This commit is contained in:
Matt Martz 2015-05-18 11:59:53 -05:00 committed by John Barker
parent b608194e59
commit 7a8862975e

View file

@ -93,11 +93,12 @@ class ModuleValidator(object):
found_has = False
if isinstance(child, ast.TryExcept):
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:
if isinstance(grandchild, ast.Import):
found_try_except_import = True
elif isinstance(grandchild, ast.Assign):
if isinstance(grandchild, ast.Assign):
for target in grandchild.targets:
if target.id.lower().startswith('has_'):
found_has = True