Skip to content

Commit 44e580f

Browse files
authored
bpo-43162: [Enum] update docs, renable doc tests (GH-24487)
* update docs, renable doc tests * make deprecation warning active for two releases
1 parent 04f6fbb commit 44e580f

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Doc/library/enum.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,17 +1222,18 @@ Private names are not converted to Enum members, but remain normal attributes.
12221222
:class:`Enum` members are instances of their :class:`Enum` class, and are
12231223
normally accessed as ``EnumClass.member``. In Python versions ``3.5`` to
12241224
``3.9`` you could access members from other members -- this practice was
1225-
discouraged, and in ``3.10`` :class:`Enum` has returned to not allowing it::
1225+
discouraged, and in ``3.12`` :class:`Enum` will return to not allowing it,
1226+
while in ``3.10`` and ``3.11`` it will raise a :exc:`DeprecationWarning`::
12261227

12271228
>>> class FieldTypes(Enum):
12281229
... name = 0
12291230
... value = 1
12301231
... size = 2
12311232
...
1232-
>>> FieldTypes.value.size
1233-
Traceback (most recent call last):
1234-
...
1235-
AttributeError: FieldTypes: no attribute 'size'
1233+
>>> FieldTypes.value.size # doctest: +SKIP
1234+
DeprecationWarning: accessing one member from another is not supported,
1235+
and will be disabled in 3.12
1236+
<FieldTypes.size: 2>
12361237

12371238
.. versionchanged:: 3.5
12381239
.. versionchanged:: 3.10

Lib/enum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def __get__(self, instance, ownerclass=None):
148148
import warnings
149149
warnings.warn(
150150
"accessing one member from another is not supported, "
151-
" and will be disabled in 3.11",
151+
" and will be disabled in 3.12",
152152
DeprecationWarning,
153153
stacklevel=2,
154154
)

Lib/test/test_enum.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
def load_tests(loader, tests, ignore):
2020
tests.addTests(doctest.DocTestSuite(enum))
21-
if os.path.exists('../../Doc/library/enum.rst'):
21+
if os.path.exists('Doc/library/enum.rst'):
2222
tests.addTests(doctest.DocFileSuite(
2323
'../../Doc/library/enum.rst',
2424
optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE,
@@ -2186,7 +2186,7 @@ class Private(Enum):
21862186
self.assertEqual(Private._Private__major_, 'Hoolihan')
21872187

21882188
@unittest.skipUnless(
2189-
sys.version_info[:2] == (3, 10),
2189+
sys.version_info[:2] < (3, 12),
21902190
'member-member access now raises an exception',
21912191
)
21922192
def test_warning_for_member_from_member_access(self):
@@ -2198,7 +2198,7 @@ class Di(Enum):
21982198
self.assertIs(Di.NO, nope)
21992199

22002200
@unittest.skipUnless(
2201-
sys.version_info[:2] > (3, 10),
2201+
sys.version_info[:2] >= (3, 12),
22022202
'member-member access currently issues a warning',
22032203
)
22042204
def test_exception_for_member_from_member_access(self):

0 commit comments

Comments
 (0)