[Python-checkins] cpython (merge 3.5 -> default): issue26893: use mro() to examine class heirarchy
ethan.furman
python-checkins at python.org
Sun May 1 13:05:00 EDT 2016
https://hg.python.org/cpython/rev/7188de6b50ab
changeset: 101204:7188de6b50ab
parent: 101202:dbdd5bc4df99
parent: 101203:1b6581bae5a1
user: Ethan Furman <ethan at stoneleaf.us>
date: Sun May 01 10:04:21 2016 -0700
summary:
issue26893: use mro() to examine class heirarchy
files:
Lib/enum.py | 2 +-
Lib/test/test_enum.py | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/Lib/enum.py b/Lib/enum.py
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -124,7 +124,7 @@
# save attributes from super classes so we know if we can take
# the shortcut of storing members in the class dict
- base_attributes = {a for b in bases for a in b.__dict__}
+ base_attributes = {a for b in enum_class.mro() for a in b.__dict__}
# Reverse value->name map for hashable values.
enum_class._value2member_map_ = {}
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -1591,6 +1591,19 @@
triple = 3
turkey = 3
+ def test_unique_with_name(self):
+ @unique
+ class Silly(Enum):
+ one = 1
+ two = 'dos'
+ name = 3
+ @unique
+ class Sillier(IntEnum):
+ single = 1
+ name = 2
+ triple = 3
+ value = 4
+
expected_help_output_with_docs = """\
Help on class Color in module %s:
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list