X Tutup
The Wayback Machine - https://web.archive.org/web/20250616121815/https://github.com/python/cpython/issues/93363
Skip to content

str.format() output for enum.Enum with str mixin changed in 3.11.0b1 #93363

Closed
@AllSeeingEyeTolledEweSew

Description

Bug report

The following script changes output between 3.10.4 (and earlier) to 3.11.0b1.

import enum
class E(str, enum.Enum):
    A = "A"
print("hello {0}".format(E.A))
$ python3.10 test.py
hello A
$ python3.11 test.py
hello E.A

Per https://docs.python.org/3/library/enum.html, I believe 3.11's behavior is wrong:

Formatted string literals, str.format(), and format() will use the mixed-in type’s __format__() unless __str__() or __format__() is overridden in the subclass

Your environment

  • CPython versions tested on: 3.10.4 and 3.11.0b1
  • Operating system and architecture: the docker images python:3.10-alpine and python:3.11-rc-alpine, on an x86_64 host

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only 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

    X Tutup