This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: re.RegexFlag.__str__ is incorrect
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Enum: __str__ and friends sometimes erroneously replaced
View: 41789
Assigned To: Nosy List: ethan.furman, ezio.melotti, mrabarnett, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-09-14 22:05 by ethan.furman, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg376911 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2020-09-14 22:05
In issue36548 - Make the repr of re flags more readable - __str__ is set to object.__str__.  Hovewer, setting __str__ to object.__str__ means that EnumMeta will replace __str__ with the first Enum's __str__ instead (Flag, in this case).

As asked in issue40066: do we want the str() and repr() to be the same, or should the str() be the plain numeric value?
msg376912 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2020-09-14 22:06
>>> import re
>>> re.I
re.IGNORECASE

>>> print(re.I)
RegexFlag.IGNORECASE    # according to comment in linked issue, this should be `re.IGNORECASE` as well
msg376925 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2020-09-15 02:14
The behavior of not honoring the object.__str__ override is a bug in Enum and currently being tracked in issue41789.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85952
2020-09-15 02:14:41ethan.furmansetstatus: open -> closed
superseder: Enum: __str__ and friends sometimes erroneously replaced
messages: + msg376925

resolution: duplicate
stage: needs patch -> resolved
2020-09-14 22:06:57ethan.furmansetmessages: + msg376912
2020-09-14 22:05:08ethan.furmancreate