diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2021-04-27 05:42:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-27 05:42:57 (GMT) |
commit | 5987b8c463892e0ab7a63cdae92f34b5eb79732d (patch) | |
tree | 1f68608c9660039046b3119828a7b596b25563cc /Misc | |
parent | cfe523b49280cdc8c239c807121ad3f33552f638 (diff) | |
download | cpython-5987b8c463892e0ab7a63cdae92f34b5eb79732d.zip cpython-5987b8c463892e0ab7a63cdae92f34b5eb79732d.tar.gz cpython-5987b8c463892e0ab7a63cdae92f34b5eb79732d.tar.bz2 |
bpo-43945: [Enum] Deprecate non-standard mixin format() behavior (GH-25649)
In 3.12 the enum member, not the member's value, will be used for
format() calls. Format specifiers can be used to retain the current
display of enum members:
Example enumeration:
class Color(IntEnum):
RED = 1
GREEN = 2
BLUE = 3
Current behavior:
f'{Color.RED}' --> '1'
Future behavior:
f'{Color.RED}' --> 'RED'
Using d specifier:
f'{Color.RED:d}' --> '1'
Using specifiers can be done now and is future-compatible.
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-04-26-20-52-16.bpo-43945.NgERXO.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-04-26-20-52-16.bpo-43945.NgERXO.rst b/Misc/NEWS.d/next/Library/2021-04-26-20-52-16.bpo-43945.NgERXO.rst new file mode 100644 index 0000000..c01c200 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-04-26-20-52-16.bpo-43945.NgERXO.rst @@ -0,0 +1,2 @@ +[Enum] Deprecate non-standard mixin format() behavior: in 3.12 the enum +member, not the member's value, will be used for format() calls. |