From 3cd6e5545165ecf3d098b6cee9a01613ea4878a9 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 14 Oct 2022 10:24:52 -0400 Subject: [PATCH 1/2] gh-98250: Improve documentation about change to Enum.__format__ --- Doc/whatsnew/3.11.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 56a35f4e4802ba..108d9dc7548362 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -624,6 +624,11 @@ enum * ``EnumMeta`` renamed to ``EnumType`` (``EnumMeta`` kept as alias). +* The output of ``Enum.__format__`` has changed to include both the enum name + and the member name (e.g. ``Enum.MEMBER``). In 3.10 and earlier it only + included the member name (e.g. ``MEMBER``). To restore the new behavior, + inherit from a subclass of ``ReprEnum``, such as ``IntEnum`` or ``StrEnum``. + * ``StrEnum`` added -- enum members are and must be strings. * ``ReprEnum`` added -- causes only the ``__repr__`` to be modified, not the From b35a09a8baedc000f0cfee9eb8355a5640935a19 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 17 Oct 2022 09:53:17 -0400 Subject: [PATCH 2/2] Add note about `__format__` used in f-strings --- Doc/whatsnew/3.11.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 108d9dc7548362..2ee8cc95a7a85a 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -624,10 +624,11 @@ enum * ``EnumMeta`` renamed to ``EnumType`` (``EnumMeta`` kept as alias). -* The output of ``Enum.__format__`` has changed to include both the enum name - and the member name (e.g. ``Enum.MEMBER``). In 3.10 and earlier it only - included the member name (e.g. ``MEMBER``). To restore the new behavior, - inherit from a subclass of ``ReprEnum``, such as ``IntEnum`` or ``StrEnum``. +* The output of ``Enum.__format__`` (which effects using enums with f-strings) + has changed to include both the enum name and the member name (e.g. + ``Enum.MEMBER``). In 3.10 and earlier it only included the member name (e.g. + ``MEMBER``). To restore the new behavior, inherit from a subclass of + ``ReprEnum``, such as ``IntEnum`` or ``StrEnum``. * ``StrEnum`` added -- enum members are and must be strings.