Skip to content

Python 3.11.0b4 str(enum) giving integer value and not name #94763

Closed
@jborean93

Description

@jborean93

Bug report

The str() method on Python 3.11.0b4 is outputting the raw integer value not the class name and label that older Python versions do.

import enum

class MyEnum(enum.IntEnum):
    TEST = 1


assert str(MyEnum.TEST) == "MyEnum.TEST", f"Actual '{MyEnum.TEST}'"

On Python 3.10 (and older Python 3 versions) this assertion is true. On python 3.11.0b4 the str value is just 1.

The repr() is the same as on older versions, just seems like str() is affected.

Your environment

  • CPython versions tested on: 3.11.0b4
  • Operating system and architecture: Linux (should be N/A though)

Metadata

Metadata

Assignees

Labels

3.11only 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