New submission from Ethan Furman <[email protected]>:
If an Enum declares __str__, __repr__, __format__, or __reduce_ex__ to be
object`s, then it will get replaced by the base Enum's corresponding method.
E.g.:
class RegexFlag(IntFlag):
IGNORECASE = I = 2
def repr(self):
return 're.%s' % self.name
__str__ = object.__str__
The intent of the above is have str(RegexFlag.I) == repr(RegexFlag.I) (with
some quotes, of course), but currently RegexFlag.__str__ will be replaced with
Flag.__str__.
----------
assignee: ethan.furman
components: Library (Lib)
messages: 376924
nosy: barry, eli.bendersky, ethan.furman
priority: normal
severity: normal
stage: needs patch
status: open
title: Enum: __str__ and friends sometimes erroneously replaced
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41789>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com