Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a77180e

Browse files
authored
gh-110905: [Enum] minor fixes and cleanup (GH-110906)
1 parent f07ca27 commit a77180e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Lib/enum.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def _is_sunder(name):
6161
return (
6262
len(name) > 2 and
6363
name[0] == name[-1] == '_' and
64-
name[1:2] != '_' and
65-
name[-2:-1] != '_'
64+
name[1] != '_' and
65+
name[-2] != '_'
6666
)
6767

6868
def _is_internal_class(cls_name, obj):
@@ -81,7 +81,6 @@ def _is_private(cls_name, name):
8181
if (
8282
len(name) > pat_len
8383
and name.startswith(pattern)
84-
and name[pat_len:pat_len+1] != ['_']
8584
and (name[-1] != '_' or name[-2] != '_')
8685
):
8786
return True
@@ -156,7 +155,6 @@ def _dedent(text):
156155
Like textwrap.dedent. Rewritten because we cannot import textwrap.
157156
"""
158157
lines = text.split('\n')
159-
blanks = 0
160158
for i, ch in enumerate(lines[0]):
161159
if ch != ' ':
162160
break
@@ -1639,7 +1637,7 @@ def _simple_enum(etype=Enum, *, boundary=None, use_args=None):
16391637
Class decorator that converts a normal class into an :class:`Enum`. No
16401638
safety checks are done, and some advanced behavior (such as
16411639
:func:`__init_subclass__`) is not available. Enum creation can be faster
1642-
using :func:`simple_enum`.
1640+
using :func:`_simple_enum`.
16431641
16441642
>>> from enum import Enum, _simple_enum
16451643
>>> @_simple_enum(Enum)

Lib/test/test_enum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class TestHelpers(unittest.TestCase):
171171

172172
sunder_names = '_bad_', '_good_', '_what_ho_'
173173
dunder_names = '__mal__', '__bien__', '__que_que__'
174-
private_names = '_MyEnum__private', '_MyEnum__still_private'
174+
private_names = '_MyEnum__private', '_MyEnum__still_private', '_MyEnum___triple_private'
175175
private_and_sunder_names = '_MyEnum__private_', '_MyEnum__also_private_'
176176
random_names = 'okay', '_semi_private', '_weird__', '_MyEnum__'
177177

0 commit comments

Comments
 (0)