Message347089
Combining int and Enum, as with enum.IntEnum results in a class where __str__ cannot be effectively overridden. For example:
from enum import IntEnum
class myIntEnum(IntEnum):
x = 1
def __str__(self):
return 'aaaaAAAa'
f'{myIntEnum.x}, {str(myIntEnum.x)}'
Expected output:
'aaaaAAAa, aaaaAAAa'
Actual output:
'1, aaaaAAAa'
Overriding __str__ in this way works as expected if the inherited classes are int or Enum individually. However, it does not work when inheriting (int, Enum) or when inheriting (intEnum).
Presumably this is a side effect of Enum's mixin behavior documented at https://docs.python.org/3/library/enum.html#others and it is possibly related to https://bugs.python.org/issue18264 . |
|
Date |
User |
Action |
Args |
2019-07-01 23:24:11 | jason.curtis | set | recipients:
+ jason.curtis |
2019-07-01 23:24:11 | jason.curtis | set | messageid: <1562023451.58.0.339794314518.issue37479@roundup.psfhosted.org> |
2019-07-01 23:24:11 | jason.curtis | link | issue37479 messages |
2019-07-01 23:24:11 | jason.curtis | create | |
|