Skip to content

Instantiation of an empty Enum with any value no longer throws ValueError #109022

Closed
@Fatal1ty

Description

@Fatal1ty

Bug report

Bug description:

On Python < 3.12 instantiation of an empty Enum with any value resulted in ValueError, but on 3.12.0rc2 it returns <enum 'bar'> without errors. On 3.12.0rc1 it resulted in TypeError: 'NoneType' object is not iterable that was addressed in this issue:

I'm not sure if it's intended or not but just in case, I'll write about it, so that if it's unintended behaviour it could be fixed before the final release. For me ValueError was more consistent but I don't see a practical reason to use empty enums anyway and I'm fine if this issue is going to be closed.

class Foo(Enum):
    pass

print(Foo('bar'))
# 3.11: ValueError: 'bar' is not a valid Foo
# 3.12.0rc1: TypeError: 'NoneType' object is not iterable
# 3.12.0rc2: <enum 'bar'>

CPython versions tested on:

3.12

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions