Skip to content

bpo-42567: [Enum] call __init_subclass__ after members are added#23714

Merged
ethanfurman merged 2 commits into
python:masterfrom
ethanfurman:enum-init_subclass
Dec 10, 2020
Merged

bpo-42567: [Enum] call __init_subclass__ after members are added#23714
ethanfurman merged 2 commits into
python:masterfrom
ethanfurman:enum-init_subclass

Conversation

@ethanfurman
Copy link
Copy Markdown
Member

@ethanfurman ethanfurman commented Dec 9, 2020

When creating an Enum, type.__new__ calls __init_subclass__, but at that point the members have not been added.

This patch suppresses the initial call, then manually calls the ancestor __init_subclass__ before returning the new Enum class.

https://bugs.python.org/issue42567

@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @ethanfurman for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @ethanfurman for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

1 similar comment
@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @ethanfurman for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Copy Markdown
Contributor

Sorry, @ethanfurman, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 6bd94de168b58ac9358277ed6f200490ab26c174 3.9

@miss-islington
Copy link
Copy Markdown
Contributor

Sorry @ethanfurman, I had trouble checking out the 3.9 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 6bd94de168b58ac9358277ed6f200490ab26c174 3.9

ethanfurman added a commit to ethanfurman/cpython that referenced this pull request Dec 15, 2020
pythonGH-23714)

When creating an Enum, type.__new__ calls __init_subclass__, but at that point the members have not been added.

This patch suppresses the initial call, then manually calls the ancestor __init_subclass__ before returning the new Enum class..
(cherry picked from commit 6bd94de)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@bedevere-bot
Copy link
Copy Markdown

GH-23772 is a backport of this pull request to the 3.9 branch.

ethanfurman added a commit that referenced this pull request Dec 15, 2020
GH-23714) (GH-23772)

When creating an Enum, `type.__new__` calls `__init_subclass__`, but at that point the members have not been added.

This patch suppresses the initial call, then manually calls the ancestor `__init_subclass__` before returning the new Enum class.
(cherry picked from commit 6bd94de)
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…honGH-23714)

When creating an Enum, type.__new__ calls __init_subclass__, but at that point the members have not been added.

This patch suppresses the initial call, then manually calls the ancestor __init_subclass__ before returning the new Enum class.
@ethanfurman ethanfurman deleted the enum-init_subclass branch April 15, 2021 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants