]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-110905: [Enum] minor fixes and cleanup (GH-110906)
authorPieter Eendebak <pieter.eendebak@gmail.com>
Mon, 16 Oct 2023 20:37:54 +0000 (22:37 +0200)
committerGitHub <noreply@github.com>
Mon, 16 Oct 2023 20:37:54 +0000 (13:37 -0700)
Lib/enum.py
Lib/test/test_enum.py

index f5448a1788e4d2b7163f5a1786fba60d0db3ec7c..7d6e51dbfea87eaa0cfeff0e4c027e3cccf72d73 100644 (file)
@@ -61,8 +61,8 @@ def _is_sunder(name):
     return (
             len(name) > 2 and
             name[0] == name[-1] == '_' and
-            name[1:2] != '_' and
-            name[-2:-1] != '_'
+            name[1] != '_' and
+            name[-2] != '_'
             )
 
 def _is_internal_class(cls_name, obj):
@@ -81,7 +81,6 @@ def _is_private(cls_name, name):
     if (
             len(name) > pat_len
             and name.startswith(pattern)
-            and name[pat_len:pat_len+1] != ['_']
             and (name[-1] != '_' or name[-2] != '_')
         ):
         return True
@@ -156,7 +155,6 @@ def _dedent(text):
     Like textwrap.dedent.  Rewritten because we cannot import textwrap.
     """
     lines = text.split('\n')
-    blanks = 0
     for i, ch in enumerate(lines[0]):
         if ch != ' ':
             break
@@ -1639,7 +1637,7 @@ def _simple_enum(etype=Enum, *, boundary=None, use_args=None):
     Class decorator that converts a normal class into an :class:`Enum`.  No
     safety checks are done, and some advanced behavior (such as
     :func:`__init_subclass__`) is not available.  Enum creation can be faster
-    using :func:`simple_enum`.
+    using :func:`_simple_enum`.
 
         >>> from enum import Enum, _simple_enum
         >>> @_simple_enum(Enum)
index 8c1f285f7b3bc214cb00947de1eca911ca958f0e..8b99c3ed78b65af7f6940ceabf6fddf49a10c6dc 100644 (file)
@@ -171,7 +171,7 @@ class TestHelpers(unittest.TestCase):
 
     sunder_names = '_bad_', '_good_', '_what_ho_'
     dunder_names = '__mal__', '__bien__', '__que_que__'
-    private_names = '_MyEnum__private', '_MyEnum__still_private'
+    private_names = '_MyEnum__private', '_MyEnum__still_private', '_MyEnum___triple_private'
     private_and_sunder_names = '_MyEnum__private_', '_MyEnum__also_private_'
     random_names = 'okay', '_semi_private', '_weird__', '_MyEnum__'