This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rmccampbell7
Recipients rmccampbell7
Date 2020-02-08.21:01:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581195691.69.0.82674637062.issue39587@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-02-08 21:01:31rmccampbell7setrecipients: + rmccampbell7
2020-02-08 21:01:31rmccampbell7setmessageid: <1581195691.69.0.82674637062.issue39587@roundup.psfhosted.org>
2020-02-08 21:01:31rmccampbell7linkissue39587 messages
2020-02-08 21:01:31rmccampbell7create