[issue41907] Regression in IntFlag behaviour in f-string

Dominic Davis-Foster report at bugs.python.org
Fri Oct 2 04:46:48 EDT 2020


Dominic Davis-Foster <dom1310df at googlemail.com> added the comment:

I believe the regression is due to GH-14545 which "fixed" bpo-37479. The news entry states:

"When `Enum.__str__` is overridden in a derived class, the override will be used by `Enum.__format__` regardless of whether mixin classes are present."

.

The change is in the __format__ method of Enum. It now checks if type(self).__str__ != Enum.__str__ and if True calls str(self). Because Flag defines its own __str__ method, the expression evaluates to True. I do not think this is the indented behaviour.

In 3.8.5 str(self) was only called if _member_type_ is object.

----------
nosy: +dom1310df

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41907>
_______________________________________


More information about the Python-bugs-list mailing list