mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497)
This commit is contained in:
parent
c168b5078f
commit
37440eef7f
3 changed files with 16 additions and 1 deletions
|
|
@ -658,7 +658,7 @@ def __format__(self, format_spec):
|
|||
# the value
|
||||
|
||||
# pure Enum branch, or branch with __str__ explicitly overridden
|
||||
str_overridden = type(self).__str__ != Enum.__str__
|
||||
str_overridden = type(self).__str__ not in (Enum.__str__, Flag.__str__)
|
||||
if self._member_type_ is object or str_overridden:
|
||||
cls = str
|
||||
val = str(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue