File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -130,22 +130,23 @@ class InstructionGroup(IntEnum):
130
130
def fromint (cls , value : int ):
131
131
"""Cast an integer to InstructionGroup type"""
132
132
# Return an invalid group if cast is not possible
133
- return (
134
- InstructionGroup (value ) if value in InstructionGroup else InstructionGroup .GRP_INVALID
135
- )
133
+ try :
134
+ return InstructionGroup (value )
135
+ except ValueError :
136
+ return InstructionGroup .GRP_INVALID
136
137
137
138
@classmethod
138
139
def from_capstone (cls , capstone_group : int ):
139
140
"""Cast a capstone group to InstructionGroup type"""
140
141
# Wrap capstone group using our custom type
141
142
# Note: This only works because the mappings between the enums are the same
142
- if capstone_group in InstructionGroup :
143
+ try :
143
144
return InstructionGroup (capstone_group )
144
-
145
- # Raise an exception if cast is not possible
146
- raise ValueError (
147
- f"Misalignment between capstone group { capstone_group } and InstructionGroup"
148
- )
145
+ except ValueError :
146
+ # Raise an exception if cast is not possible
147
+ raise ValueError (
148
+ f"Misalignment between capstone group { capstone_group } and InstructionGroup"
149
+ )
149
150
150
151
151
152
@enum_tools .documentation .document_enum
You can’t perform that action at this time.
0 commit comments