Skip to content

Commit b9ca3c7

Browse files
committed
Fix for for python >= 3.11
Until python 3.11 IntEnum.srt() returned "<Enum name>.<member name>" But since then it returns the string of its numeric value instead. This causes errors like: File "edtt/src/components/attdata.py", line 374, in __str__ result = self.__opcodeName( opcode ); ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "edtt/src/components/attdata.py", line 349, in __opcodeName result = result.split('.')[1]; ~~~~~~~~~~~~~~~~~^^^ Let's pick the "name" instead which is directly the Enum member name. This works both with newer and older python versions since enum was added in version 3.4. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent fe9b1d1 commit b9ca3c7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/components/attdata.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,12 @@ def decode(self, data):
339339
return result;
340340

341341
def __errorText(self, error):
342-
result = str(ATTError( error ));
343-
result = result.split('.')[1];
342+
result = ATTError(error).name;
344343
result = '_'.join([_.lower().capitalize() if _ != 'ATT' else _ for _ in result.split('_')]);
345344
return result;
346345

347346
def __opcodeName(self, opcode):
348-
result = str(ATTOpcode( opcode ));
349-
result = result.split('.')[1];
347+
result = ATTOpcode(opcode).name;
350348
result = '_'.join([_.lower().capitalize() if _ != 'ATT' else _ for _ in result.split('_')]);
351349
return result;
352350

0 commit comments

Comments
 (0)