summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorthatneat <thatneat@users.noreply.github.com>2019-07-04 18:28:37 (GMT)
committerEthan Furman <ethan@stoneleaf.us>2019-07-04 18:28:37 (GMT)
commit2f19e82fbe98ce86bcd98a176328af2808b678e8 (patch)
tree0febe00f3456e58aa82575a2c16a62f3e2385c6a /Lib/enum.py
parentb4e68960b90627422325fdb75f463df1e4153c6e (diff)
downloadcpython-2f19e82fbe98ce86bcd98a176328af2808b678e8.zip
cpython-2f19e82fbe98ce86bcd98a176328af2808b678e8.tar.gz
cpython-2f19e82fbe98ce86bcd98a176328af2808b678e8.tar.bz2
bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ (GH-14545)
* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index 403f747..69a7f49 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