[New-bugs-announce] [issue45493] str() and repr() of enum different in Python 3.11 from from Python <= 3.10

Dutcho report at bugs.python.org
Sat Oct 16 06:58:57 EDT 2021


New submission from Dutcho <dutcho at ziggo.nl>:

See below example, which shows Python 3.11 repr(enum) == Python 3.10 str(enum).

The enum module documentation lists various enhancements in 3.11, but not this.
And the what's new? documentation of 3.11 doesn't mention enum at all.

Either this is by intent, and then should be documented incl. breaking old code depending on representation, or is by accident, and then merits fixing (which is what alphas are for).

> py -3.10 enum_test.py
3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]
ABC.a ABC.b ABC.c ABC.a <ABC.a: 1>

> py -3.11 enum_test.py
3.11.0a1 (tags/v3.11.0a1:7c12e48, Oct  5 2021, 15:38:19) [MSC v.1929 64 bit (AMD64)]
a b c a ABC.a

> more enum_test.py
import enum
import sys


class ABC(enum.Enum):
    a = enum.auto()
    b = enum.auto()
    c = enum.auto()


print(sys.version)
print(*ABC, str(ABC.a), repr(ABC.a))

----------
components: Library (Lib)
messages: 404069
nosy: Dutcho
priority: normal
severity: normal
status: open
title: str() and repr() of enum different in Python 3.11 from from Python <= 3.10
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45493>
_______________________________________


More information about the New-bugs-announce mailing list