Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enum creation from values fails for certain values. #116040

Closed
Assignees
ethanfurman
Labels
3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@maflAT

Description

@maflAT

Bug report

Bug description:

Hello,
I tried to define an enum with custom initializer and tuple values, akin to thePlanet example.
When instantiating this enum from values it works for some values (0, 1) but fails for others (1, 0).

fromenumimportEnumclassCardinal(Enum):RIGHT= (1,0)UP= (0,1)LEFT= (-1,0)DOWN= (0,-1)def__init__(self,x:int,y:int,/)->None:self.x=xself.y=yup=Cardinal(0,1)# worksright=Cardinal(1,0)# ValueError: 1 is not a valid Cardinalright_=Cardinal((1,0))# works

I'm not quite sure if I'm allowed to construct this enum from separate x and y parameters or if I need to pass a tuple.
Either way, it should either work for both (up and right) cases or fail for both cases.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp