Skip to content

gh-112328: [Enum] Make some private attributes public.#112514

Merged
ethanfurman merged 6 commits into
python:mainfrom
ethanfurman:enum-private_public
Dec 5, 2023
Merged

gh-112328: [Enum] Make some private attributes public.#112514
ethanfurman merged 6 commits into
python:mainfrom
ethanfurman:enum-private_public

Conversation

@ethanfurman

@ethanfurman ethanfurman commented Nov 29, 2023

Copy link
Copy Markdown
Member
  • _EnumDict --> EnumDict
  • EnumDict._member_names --> EnumDict.member_names
  • Enum._add_alias_
  • Enum._add_value_alias_

📚 Documentation preview 📚: https://cpython-previews--112514.org.readthedocs.build/

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``EnumType._add_alias_``
- ``EnumType._add_value_alias_``
@ethanfurman ethanfurman added type-feature A feature request or enhancement tests Tests in the Lib/test dir docs Documentation in the Doc dir stdlib Standard Library Python modules in the Lib/ directory 3.13 bugs and security fixes labels Nov 29, 2023
@ethanfurman ethanfurman requested a review from sobolevn November 29, 2023 05:09
@ethanfurman ethanfurman self-assigned this Nov 29, 2023

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work! The main question I have, since I am not as deep in the context of enum as you are, what is the main motivation for this? The issue does not have any details :(

Comment thread Doc/howto/enum.rst Outdated
- :attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a
:class:`str`, that will not be transformed into members, and will be removed
from the final class
- :attr:`~Enum._order_` -- used in Python 2/3 code to ensure member order is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop Python2 part.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping for now -- I'll probably change _order_ to be definitive so Enum still works on python implementations without ordered dictionaries.

Comment thread Doc/library/enum.rst
Comment thread Doc/howto/enum.rst Outdated
Comment thread Lib/enum.py Outdated
Comment thread Lib/enum.py Outdated

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the syntax in enum.rst is incorrect currently:

Comment thread Doc/library/enum.rst Outdated
Comment thread Doc/library/enum.rst Outdated
Comment thread Doc/library/enum.rst Outdated
@bedevere-app

bedevere-app Bot commented Nov 29, 2023

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Comment thread Doc/howto/enum.rst Outdated
Comment thread Lib/enum.py Outdated
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood AlexWaygood dismissed their stale review November 29, 2023 15:42

Requested changes were made

@ethanfurman

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again.

I also moved the two _add_* methods from EnumType to Enum, and fixed unhashable value handling.

@ethanfurman ethanfurman merged commit de6bca9 into python:main Dec 5, 2023
@ethanfurman ethanfurman deleted the enum-private_public branch December 5, 2023 16:27
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…H-112514)

* [Enum] Make some private attributes public.

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``Enum._add_alias_``
- ``Enum._add_value_alias_``

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@ethanfurman ethanfurman added 3.12 only security fixes needs backport to 3.12 only security fixes labels Apr 9, 2024
@miss-islington-app

Copy link
Copy Markdown

Thanks @ethanfurman for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @ethanfurman, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker de6bca956432cc852a4a41e2a2cee9cdacd19f35 3.12

@ethanfurman

Copy link
Copy Markdown
Member Author

Backporting because changes are needed for a bug-fix.

Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…H-112514)

* [Enum] Make some private attributes public.

- ``_EnumDict`` --> ``EnumDict``
- ``EnumDict._member_names`` --> ``EnumDict.member_names``
- ``Enum._add_alias_``
- ``Enum._add_value_alias_``

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@hugovk

hugovk commented Feb 26, 2025

Copy link
Copy Markdown
Member

Backporting because changes are needed for a bug-fix.

@ethanfurman Triage: Is this still the case? If so, please could you create the 3.12 backport? Otherwise let's remove the backport label.

@hugovk

hugovk commented Apr 8, 2025

Copy link
Copy Markdown
Member

3.12 is now security-only, so the backport is no longer needed.

https://discuss.python.org/t/python-3-12-is-now-security-fix-only/87520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.13 bugs and security fixes docs Documentation in the Doc dir stdlib Standard Library Python modules in the Lib/ directory tests Tests in the Lib/test dir type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants