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.

Title: Enum Flag: psuedo-members have None for name attribute
Type: enhancement Stage: resolved
Components: Versions: Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder: enum.Flag should be more set-like
View: 38250
Assigned To: ethan.furman Nosy List: ethan.furman, fbidu, iritkatriel, rahul-kumi
Priority: normal Keywords:

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

Messages (4)
msg369223 - (view) Author: Felipe Rodrigues (fbidu) * Date: 2020-05-18 14:05

Can you elaborate on this?

msg377426 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-09-23 21:36
I believe this is what Rahul means:

import enum
class Color(enum.Flag):
    RED =
    BLUE =
    GREEN =

white = Color.RED | Color.BLUE | Color.GREEN
assert is None

#  Note, however that:
assert str(Color.RED | Color.BLUE | Color.GREEN) == "Color.GREEN|BLUE|RED"
msg377521 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-09-26 10:29
I see in the code of _create_pseudo_member_ that _name_ is deliberately set to None, and furthermore in __str__ and __repr__ the fact that it is None is used to determine whether self is a composite (pseudo) or not.

So first question is whether this should be fixed.

If so, I see two options:

1. Establish another way to determine whether self is a composite or not, and change they way _name_ is initialised.

2. Leave _name_ as is, but override name (which currently is defined in Enum and simply returns _name_ but can be redefined to do something else).
msg386102 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2021-02-01 20:13
This issue is fixed in #38250.
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84223
2021-02-01 20:13:25ethan.furmansetstatus: open -> closed
superseder: enum.Flag should be more set-like
messages: + msg386102

resolution: fixed
stage: needs patch -> resolved
2020-09-26 10:29:14iritkatrielsetmessages: + msg377521
2020-09-23 21:36:56iritkatrielsetnosy: + iritkatriel
messages: + msg377426
2020-05-18 16:40:45rahul-kumisetnosy: + rahul-kumi
2020-05-18 14:05:38fbidusetnosy: + fbidu
messages: + msg369223
2020-03-22 12:45:55ethan.furmansettype: enhancement
2020-03-22 12:45:27ethan.furmancreate