Skip to content

Conversation

@aescolar
Copy link
Collaborator

@aescolar aescolar commented Aug 27, 2024

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.


https://docs.python.org/3/library/enum.html#enum.IntEnum

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 <alberto.escolar.piedras@nordicsemi.no>
Copy link
Collaborator

@mtpr-ot mtpr-ot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aescolar aescolar merged commit b9ca3c7 into EDTTool:main Aug 27, 2024
@aescolar aescolar deleted the enum_3.11_fix branch August 27, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants