summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index 9114c5c..9c0af9e 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -865,6 +865,8 @@ class EnumType(type):
value = first_enum._generate_next_value_(name, start, count, last_values[:])
last_values.append(value)
names.append((name, value))
+ if names is None:
+ names = ()
# Here, names is either an iterable of (name, value) or a mapping.
for item in names:
@@ -1121,6 +1123,11 @@ class Enum(metaclass=EnumType):
for member in cls._member_map_.values():
if member._value_ == value:
return member
+ # still not found -- verify that members exist, in-case somebody got here mistakenly
+ # (such as via super when trying to override __new__)
+ if not cls._member_map_:
+ raise TypeError("%r has no members defined" % cls)
+ #
# still not found -- try _missing_ hook
try:
exc = None