summaryrefslogtreecommitdiff
path: root/Lib/enum.py
diff options
context:
space:
mode:
authororlnub123 <orlnub123@gmail.com>2018-09-10 19:39:48 +0300
committerEthan Furman <ethan@stoneleaf.us>2018-09-10 09:39:48 -0700
commitc0d63bf73b35df374e6e66c08b0e297fb828d744 (patch)
treecf31a3cfa56b595b26d107f9268037760c5911a8 /Lib/enum.py
parent49020174305ca3dc90a811b03a05f44873297c61 (diff)
downloadcpython-git-c0d63bf73b35df374e6e66c08b0e297fb828d744.tar.gz
[3.7] bpo-34282: Fix Enum._convert method shadowing members named _convert (GH-9034)
* Fix Enum._convert shadowing members named _convert
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index 576de03180..69b41fe7cb 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -171,9 +171,11 @@ class EnumMeta(type):
enum_class._member_map_ = OrderedDict() # name->value map
enum_class._member_type_ = member_type
- # 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 enum_class.mro() for a in b.__dict__}
+ # save DynamicClassAttribute attributes from super classes so we know
+ # if we can take the shortcut of storing members in the class dict
+ dynamic_attributes = {k for c in enum_class.mro()
+ for k, v in c.__dict__.items()
+ if isinstance(v, DynamicClassAttribute)}
# Reverse value->name map for hashable values.
enum_class._value2member_map_ = {}
@@ -233,7 +235,7 @@ class EnumMeta(type):
enum_class._member_names_.append(member_name)
# performance boost for any member that would not shadow
# a DynamicClassAttribute
- if member_name not in base_attributes:
+ if member_name not in dynamic_attributes:
setattr(enum_class, member_name, enum_member)
# now add to _member_map_
enum_class._member_map_[member_name] = enum_member