Message361635
In Python 3.6 the following works:
class HexInt(int):
def __repr__(self):
return hex(self)
class MyEnum(HexInt, enum.Enum):
A = 1
B = 2
C = 3
>>> MyEnum.A
<MyEnum.A: 0x1>
However in Python 3.7/8 it instead prints
>>> MyEnum.A
0x1
It uses HexInt's repr instead of Enum's. Looking at the enum.py module it seems that this occurs for mixin classes that don't define __new__ due to a change in the _get_mixins_ method. If I define a __new__ method on the HexInt class then the expected behavior occurs. |
|
Date |
User |
Action |
Args |
2020-02-08 21:01:31 | rmccampbell7 | set | recipients:
+ rmccampbell7 |
2020-02-08 21:01:31 | rmccampbell7 | set | messageid: <1581195691.69.0.82674637062.issue39587@roundup.psfhosted.org> |
2020-02-08 21:01:31 | rmccampbell7 | link | issue39587 messages |
2020-02-08 21:01:31 | rmccampbell7 | create | |
|