Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6a8e0fbc
Commit
6a8e0fbc
authored
Sep 16, 2014
by
Ethan Furman
Browse files
Options
Browse Files
Download
Plain Diff
consistently use _name_ and _value_; patch from Kiss Gyorgy
parents
6cfa46e4
0081f23a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Lib/enum.py
Lib/enum.py
+5
-5
No files found.
Lib/enum.py
View file @
6a8e0fbc
...
...
@@ -159,7 +159,7 @@ class EnumMeta(type):
# If another member with the same value was already defined, the
# new member becomes an alias to the existing one.
for
name
,
canonical_member
in
enum_class
.
_member_map_
.
items
():
if
canonical_member
.
value
==
enum_member
.
_value_
:
if
canonical_member
.
_value_
==
enum_member
.
_value_
:
enum_member
=
canonical_member
break
else
:
...
...
@@ -224,7 +224,7 @@ class EnumMeta(type):
return
cls
.
_create_
(
value
,
names
,
module
=
module
,
qualname
=
qualname
,
type
=
type
)
def
__contains__
(
cls
,
member
):
return
isinstance
(
member
,
cls
)
and
member
.
name
in
cls
.
_member_map_
return
isinstance
(
member
,
cls
)
and
member
.
_name_
in
cls
.
_member_map_
def
__delattr__
(
cls
,
attr
):
# nicer error message when someone tries to delete an attribute
...
...
@@ -452,9 +452,9 @@ class Enum(metaclass=EnumMeta):
except
TypeError
:
# not there, now do long search -- O(n) behavior
for
member
in
cls
.
_member_map_
.
values
():
if
member
.
value
==
value
:
if
member
.
_value_
==
value
:
return
member
raise
ValueError
(
"%
s
is not a valid %s"
%
(
value
,
cls
.
__name__
))
raise
ValueError
(
"%
r
is not a valid %s"
%
(
value
,
cls
.
__name__
))
def
__repr__
(
self
):
return
"<%s.%s: %r>"
%
(
...
...
@@ -480,7 +480,7 @@ class Enum(metaclass=EnumMeta):
# mix-in branch
else
:
cls
=
self
.
_member_type_
val
=
self
.
value
val
=
self
.
_value_
return
cls
.
__format__
(
val
,
format_spec
)
def
__hash__
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment