]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-43945: [Enum] reduce scope of new format() behavior (GH-26752)
authorEthan Furman <ethan@stoneleaf.us>
Fri, 18 Jun 2021 20:15:46 +0000 (13:15 -0700)
committerGitHub <noreply@github.com>
Fri, 18 Jun 2021 20:15:46 +0000 (13:15 -0700)
commitf60b07ab6c943fce084772c3c7731ab3bbd213ff
treea9c172b4ce1f0bed84d026738344be40037ea2b5
parentdf1502e47fc1e0cf1e7d460ae04530c3e2e4a7c6
bpo-43945: [Enum] reduce scope of new format() behavior (GH-26752)

* [Enum] reduce scope of new format behavior

Instead of treating all Enums the same for format(), only user mixed-in
enums will be affected.  In other words, IntEnum and IntFlag will not be
changing the format() behavior, due to the requirement that they be
drop-in replacements of existing integer constants.

If a user creates their own integer-based enum, then the new behavior
will apply:

    class Grades(int, Enum):
        A = 5
        B = 4
        C = 3
        D = 2
        F = 0

Now:  format(Grades.B)  -> DeprecationWarning and '4'
3.12:                   -> no warning, and 'B'
Doc/library/enum.rst
Lib/asyncio/unix_events.py
Lib/enum.py
Lib/test/test_enum.py
Lib/test/test_httpservers.py