-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The _is_private
method has incorrect results on attributes starting with a triple underscore. Example:
import enum
enum._is_private('X', '_X___test') # returns True
The relevant code is:
def _is_private(cls_name, name):
pattern = '_%s__' % (cls_name, )
pat_len = len(pattern)
if (
len(name) > pat_len
and name.startswith(pattern)
and name[pat_len:pat_len+1] != ['_']
and (name[-1] != '_' or name[-2] != '_')
):
return True
else:
return False
The check name[pat_len:pat_len+1] != ['_']
is always False
, since name[pat_len:pat_len+1]
is a str
and ['_']
a list.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error