diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2021-01-13 07:47:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-13 07:47:57 (GMT) |
commit | c314e60388282d9829762fb6c30b12e2807caa19 (patch) | |
tree | 1c49d06b9882fec1c77d0a091baf9c0b93230e4f /Misc/NEWS.d/next/Library | |
parent | c47c78b878ff617164b2b94ff711a6103e781753 (diff) | |
download | cpython-c314e60388282d9829762fb6c30b12e2807caa19.zip cpython-c314e60388282d9829762fb6c30b12e2807caa19.tar.gz cpython-c314e60388282d9829762fb6c30b12e2807caa19.tar.bz2 |
bpo-42901: [Enum] move member creation to `__set_name__` (GH-24196)
`type.__new__` calls `__set_name__` and `__init_subclass__`, which means
that any work metaclasses do after calling `super().__new__()` will not
be available to those two methods. In particular, `Enum` classes that
want to make use of `__init_subclass__` will not see any members.
Almost all customization is therefore moved to before the
`type.__new__()` call, including changing all members to a proto member
descriptor with a `__set_name__` that will do the final conversion of a
member to be an instance of the `Enum` class.
Diffstat (limited to 'Misc/NEWS.d/next/Library')
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-01-11-17-36-59.bpo-42901.gFd-ta.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-01-11-17-36-59.bpo-42901.gFd-ta.rst b/Misc/NEWS.d/next/Library/2021-01-11-17-36-59.bpo-42901.gFd-ta.rst new file mode 100644 index 0000000..206bca1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-01-11-17-36-59.bpo-42901.gFd-ta.rst @@ -0,0 +1,3 @@ +[Enum] move member creation from ``EnumMeta.__new__`` to +``_proto_member.__set_name__``, allowing members to be created and visible +in ``__init_subclass__``. |