Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Dec 10, 2020

Conversation

ethanfurman
Copy link
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

@ethanfurman ethanfurman merged commit 6bd94de into python:master Dec 10, 2020
@ethanfurman ethanfurman added the needs backport to 3.9 only security fixes label Dec 10, 2020
@miss-islington
Copy link
Contributor

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

@Mariatta Mariatta added needs backport to 3.9 only security fixes and removed needs backport to 3.9 only security fixes labels Dec 13, 2020
@miss-islington
Copy link
Contributor

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

1 similar comment
@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
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
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

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

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Dec 15, 2020
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