]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.9] bpo-42567: [Enum] call __init_subclass__ after members are added (GH-23714...
authorEthan Furman <ethan@stoneleaf.us>
Tue, 15 Dec 2020 02:41:34 +0000 (18:41 -0800)
committerGitHub <noreply@github.com>
Tue, 15 Dec 2020 02:41:34 +0000 (18:41 -0800)
commit9d1fff1fcd5332f0ba7f72d0e0f9f66b47ec4e8d
tree5a69e2472d0fe8fe719c1ef97b14b3f08da867a1
parentaba12b67c18b17bb727a0d50dd0653e38cb64dc8
[3.9] bpo-42567: [Enum] call __init_subclass__ after members are added (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 6bd94de168b58ac9358277ed6f200490ab26c174)
Lib/enum.py
Lib/test/test_enum.py
Misc/NEWS.d/next/Library/2020-12-08-22-43-35.bpo-42678.ba9ktU.rst [new file with mode: 0644]