New submission from Ryan McCampbell <rmccampbe...@gmail.com>:
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. ---------- components: Library (Lib) messages: 361635 nosy: rmccampbell7 priority: normal severity: normal status: open title: Mixin repr overrides Enum repr in some cases type: behavior versions: Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39587> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com