diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-06 03:10:04 (GMT) |
---|---|---|
committer | Ethan Furman <ethan@stoneleaf.us> | 2018-10-06 03:10:04 (GMT) |
commit | 22e86fbbca04d251233fc07515885d2b67945094 (patch) | |
tree | 50e9219a5b17fe327e3712299a271c06261d34f3 /Lib/enum.py | |
parent | 526929be39e139a7d89f4c363d79c28566f30d71 (diff) | |
download | cpython-22e86fbbca04d251233fc07515885d2b67945094.zip cpython-22e86fbbca04d251233fc07515885d2b67945094.tar.gz cpython-22e86fbbca04d251233fc07515885d2b67945094.tar.bz2 |
[3.7] bpo-34282: Fix Enum._convert method shadowing members named _convert (GH-9034) (GH-9229)
* Fix Enum._convert shadowing members named _convert
Co-authored-by: orlnub123 <orlnub123@gmail.com>
Diffstat (limited to 'Lib/enum.py')
-rw-r--r-- | Lib/enum.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index 112523e..8405fa9 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -155,9 +155,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_ = {} @@ -217,7 +219,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 |