Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-100458: Clarify Enum.__format__() change of mixed-in types in the whatsnew/3.11.rst#100387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedDec 21, 2022 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>
anze3db commentedDec 27, 2022
@JosephSBoyle thank you! I've added your changes. Let me know if there is anything else needed from my side. Should I also open a PR against the 3.11 branch? |
ethanfurman commentedDec 27, 2022
@anze3db No need, once this is committed a backport PR will be automatically created. |
anze3db commentedJan 31, 2023
@JosephSBoyle there was more than a month of inactivity on this PR 😞 Anything I can do to help this getting merged? |
JosephSBoyle commentedJan 31, 2023
Hi@anze3db, I'm not a maintainer so perhaps this is a better question for@AlexWaygood. If the assigned reviewer is busy perhaps another reviewer can be assigned. |
Bktero commentedMar 22, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Will this PR finds its way to the next version of Python? Further question: is this change documented herehttps://docs.python.org/3/library/enum.html ? I can't spot it... |
ethanfurman left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
My apologies -- I didn't get the [Submit Review] button pressed.
Doc/whatsnew/3.11.rst Outdated
| (the default for:func:`format`,:meth:`str.format` and:term:`f-string`\s) | ||
| of enums with mixed-in types (e.g.:class:`int`,:class:`str`) | ||
| toalsoinclude the class name in the output, notjustthe member'skey. | ||
| to include the class nameand member keyin the output, not the member'svalue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| toinclude the class name and memberkey in the output,not the member's value. | |
| toshow the class name and membername in the output,instead of the member's value. |
Doc/whatsnew/3.11.rst Outdated
| toalsoinclude the class name in the output, notjustthe member'skey. | ||
| to include the class nameand member keyin the output, not the member'svalue. | ||
| This matches the existing behavior of:meth:`enum.Enum.__str__`, | ||
| returning e.g. ``'AnEnum.MEMBER'`` for an enum ``AnEnum(str, Enum)`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| returning e.g. ``'AnEnum.MEMBER'`` for an enum ``AnEnum(str, Enum)`` | |
| returning e.g. ``'AnEnum.MEMBER'`` for an enum ``AnEnum(str, Enum)``. |
Doc/whatsnew/3.11.rst Outdated
| This matches the existing behavior of:meth:`enum.Enum.__str__`, | ||
| returning e.g. ``'AnEnum.MEMBER'`` for an enum ``AnEnum(str, Enum)`` | ||
| instead of just ``'MEMBER'``. | ||
| instead of the member's value. Those wishing to keep the old formatting behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| instead of the member's value.Those wishing to keep the old formatting behavior | |
| Those wishing to keep the old formatting behavior |
bedevere-bot commentedMar 22, 2023
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
anze3db commentedMar 22, 2023
I have made the requested changes; please review again. |
bedevere-bot commentedMar 22, 2023
Thanks for making the requested changes! @ethanfurman: please review the changes made to this pull request. |
anze3db commentedApr 13, 2023
@ethanfurman just a friendly reminder to re-review this if you have the time, thanks! |
ethanfurman left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Did some rewriting in an attempt to make it clearer.
Thoughts on the new changes?
miss-islington commentedMay 1, 2023
Thanks@anze3db for the PR, and@ethanfurman for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
…n the whatsnew/3.11.rst (pythonGH-100387)(cherry picked from commite665563)Co-authored-by: Anže Pečar <anze@pecar.me>Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
bedevere-bot commentedMay 1, 2023
GH-104060 is a backport of this pull request to the3.11 branch. |
* main: (463 commits)pythongh-104057: Fix direct invocation of test_super (python#104064)pythongh-87092: Expose assembler to unit tests (python#103988)pythongh-97696: asyncio eager tasks factory (python#102853)pythongh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (pythongh-104054)pythongh-104057: Fix direct invocation of test_module (pythonGH-104059)pythongh-100458: Clarify Enum.__format__() change of mixed-in types in the whatsnew/3.11.rst (pythonGH-100387)pythongh-104018: disallow "z" format specifier in %-format of byte strings (pythonGH-104033)pythongh-104016: Fixed off by 1 error in f string tokenizer (python#104047)pythonGH-103629: Update Unpack's repr in compliance with PEP 692 (python#104048)pythongh-102799: replace sys.exc_info by sys.exception in inspect and traceback modules (python#104032) Fix typo in "expected" word in few source files (python#104034)pythongh-103824: fix use-after-free error in Parser/tokenizer.c (python#103993)pythongh-104035: Do not ignore user-defined `__{get,set}state__` in slotted frozen dataclasses (python#104041)pythongh-104028: Reduce object creation while calling callback function from gc (pythongh-104030)pythongh-104036: Fix direct invocation of test_typing (python#104037)pythongh-102213: Optimize the performance of `__getattr__` (pythonGH-103761)pythongh-103895: Improve how invalid `Exception.__notes__` are displayed (python#103897) Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (pythonGH-104021)pythongh-88496: Fix IDLE test hang on macOS (python#104025) Improve int test coverage (python#104024) ...
Uh oh!
There was an error while loading.Please reload this page.
Hey! 👋
Please correct me if I'm wrong, but the description of the changeEnum.format() change in 3.11.rst doesn't seem accurate. The behavior in older Python versions was to return the member's value and not the member's key as is currently stated. Example code:
Running this on Python 3.10 prints:
And not
as the changelog states:
I noticed this because we were using the
strmixin with all Enum classes as a hack to get to the value without needing to writeFoo.BAR.value🫣 The new behavior in Python 3.11 broke our code and the current phrasing in the changelog makes it feel this was just a minor bugfix. Should this change be a bit more prominent since it can be a breaking change?By the way, thank you for adding
StrEnum, it's exactly what we needed!PS: Not sure if this needs a GitHub issue number, it's not exactly a typo, but it's still a minor change.
I'm happy to open an issue if needed.Issue linked below. Also let me know if I need to open the PR against any other branches as well. 🙇strorintMixin Breaking Change in Python 3.11 #100458