diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2013-07-25 20:50:45 (GMT) |
---|---|---|
committer | Ethan Furman <ethan@stoneleaf.us> | 2013-07-25 20:50:45 (GMT) |
commit | b41803e3ef65624ce39a4bcf4caff6ff1184699f (patch) | |
tree | 8c3380a6dbce75d34e6058087881f9b9e7dd5c33 /Lib/enum.py | |
parent | 4d35e75ca069b51ffdac7b34dad4ffb77e72a598 (diff) | |
download | cpython-b41803e3ef65624ce39a4bcf4caff6ff1184699f.zip cpython-b41803e3ef65624ce39a4bcf4caff6ff1184699f.tar.gz cpython-b41803e3ef65624ce39a4bcf4caff6ff1184699f.tar.bz2 |
Close #18545: now only executes member_type if no _value_ is assigned in __new__.
Diffstat (limited to 'Lib/enum.py')
-rw-r--r-- | Lib/enum.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index 0def138..33af042 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -152,12 +152,12 @@ class EnumMeta(type): args = (args, ) # wrap it one more time if not use_args: enum_member = __new__(enum_class) - original_value = value + if not hasattr(enum_member, '_value_'): + enum_member._value_ = value else: enum_member = __new__(enum_class, *args) - original_value = member_type(*args) - if not hasattr(enum_member, '_value_'): - enum_member._value_ = original_value + if not hasattr(enum_member, '_value_'): + enum_member._value_ = member_type(*args) value = enum_member._value_ enum_member._member_type_ = member_type enum_member._name_ = member_name |