diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2022-07-25 18:05:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 18:05:10 (GMT) |
commit | 4e704d7847f2333f581f87e31b42e44a471df93a (patch) | |
tree | 246f0b4061cdb9130f67dabda15d17aec7cff02d /Doc/howto/enum.rst | |
parent | 73ee5a6b865fbd2e89b5b1f0a33bd7bcc7176c21 (diff) | |
download | cpython-4e704d7847f2333f581f87e31b42e44a471df93a.zip cpython-4e704d7847f2333f581f87e31b42e44a471df93a.tar.gz cpython-4e704d7847f2333f581f87e31b42e44a471df93a.tar.bz2 |
gh-95077: [Enum] add code-based deprecation warnings for member.member access (GH-95083)
* issue deprecation warning for member.member access
* always store member property in current class
* remove __getattr__
Diffstat (limited to 'Doc/howto/enum.rst')
-rw-r--r-- | Doc/howto/enum.rst | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/Doc/howto/enum.rst b/Doc/howto/enum.rst index 7b1cf75..376934a 100644 --- a/Doc/howto/enum.rst +++ b/Doc/howto/enum.rst @@ -945,23 +945,12 @@ but remain normal attributes. """""""""""""""""""" Enum members are instances of their enum class, and are normally accessed as -``EnumClass.member``. In Python versions ``3.5`` to ``3.10`` you could access -members from other members -- this practice was discouraged, and in ``3.11`` -:class:`Enum` returns to not allowing it:: - - >>> class FieldTypes(Enum): - ... name = 0 - ... value = 1 - ... size = 2 - ... - >>> FieldTypes.value.size - Traceback (most recent call last): - ... - AttributeError: <enum 'FieldTypes'> member has no attribute 'size' - +``EnumClass.member``. In Python versions starting with ``3.5`` you could access +members from other members -- this practice is discouraged, is deprecated +in ``3.12``, and will be removed in ``3.14``. .. versionchanged:: 3.5 -.. versionchanged:: 3.11 +.. versionchanged:: 3.12 Creating members that are mixed with other data types |