Skip to content

Commit

Permalink
bpo-42901: [Enum] move member creation to __set_name__ (GH-24196)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
ethanfurman committed Jan 13, 2021
1 parent c47c78b commit c314e60
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 110 deletions.
Loading

0 comments on commit c314e60

Please sign in to comment.