Skip to content

Commit

Permalink
Fix a crash caused by accessing is_enum on a non-class.
Browse files Browse the repository at this point in the history
Noticed this while testing another change.

PiperOrigin-RevId: 482555441
  • Loading branch information
rchen152 committed Oct 20, 2022
1 parent a425494 commit e53ce6c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pytype/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def add_branch(self, op: opcodes.Opcode, match_var: cfg.Variable,
except abstract_utils.ConversionError:
return None
# We currently only implement exhaustiveness matching for enums.
if not (isinstance(match_val, abstract.Instance) and match_val.cls.is_enum):
if not (isinstance(match_val, abstract.Instance) and
isinstance(match_val.cls, abstract.Class) and
match_val.cls.is_enum):
return None
if not (isinstance(case_val, abstract.Instance) and
case_val.cls == match_val.cls):
Expand Down

0 comments on commit e53ce6c

Please sign in to comment.