]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-109022: [Enum] require `names=()` to create empty enum type (GH-109048...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 12 Sep 2023 13:53:16 +0000 (06:53 -0700)
committerGitHub <noreply@github.com>
Tue, 12 Sep 2023 13:53:16 +0000 (15:53 +0200)
commitca848bbf78cf82447cc5c2fe6822c82f6f9e59c4
tree6ea447912f1d9324f03a0d9dfe4e3bc57d1cac61
parentd533ab17ec37b457a5cc286f30c7559e358492bf
[3.12] gh-109022: [Enum] require `names=()` to create empty enum type (GH-109048) (#109122)

gh-109022: [Enum] require `names=()` to create empty enum type (GH-109048)

add guard so that ``Enum('bar')`` raises a TypeError instead of
creating a new enum class called `bar`.  To create the new but
empty class, use:

    huh = Enum('bar', names=())
(cherry picked from commit c74e440168fab9bf91346471087a394af13fa2db)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Lib/enum.py
Lib/test/test_enum.py
Misc/NEWS.d/next/Library/2023-09-06-19-33-41.gh-issue-108682.35Xnc5.rst [new file with mode: 0644]