mirror of
https://github.com/python/cpython.git
synced 2025-08-24 02:35:59 +00:00
bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ (GH-14545)
* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
This commit is contained in:
parent
b4e68960b9
commit
2f19e82fbe
5 changed files with 63 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue