From 2f19e82fbe98ce86bcd98a176328af2808b678e8 Mon Sep 17 00:00:00 2001 From: thatneat Date: Thu, 4 Jul 2019 11:28:37 -0700 Subject: bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ (GH-14545) * bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ --- Lib/enum.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Lib/enum.py') diff --git a/Lib/enum.py b/Lib/enum.py index 403f747d22..69a7f49d80 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -622,8 +622,9 @@ class Enum(metaclass=EnumMeta): # we can get strange results with the Enum name showing up instead of # the value - # pure Enum branch - if self._member_type_ is object: + # pure Enum branch, or branch with __str__ explicitly overridden + str_overridden = type(self).__str__ != Enum.__str__ + if self._member_type_ is object or str_overridden: cls = str val = str(self) # mix-in branch -- cgit v1.2.1