This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Gerrit.Holl
Recipients Gerrit.Holl
Date 2017-06-09.17:30:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1497029417.9.0.731294800985.issue30616@psf.upfronthosting.co.za>
In-reply-to
Content
The OO API allows to create empty enums, i.e. without any values.  However, the functional API does not, as this will result in an IndexError as shown below:

In [1]: import enum

In [2]: class X(enum.IntFlag): pass

In [3]: Y = enum.IntFlag("Y", [])
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-3-1fda5945e0b2> in <module>()
----> 1 Y = enum.IntFlag("Y", [])

~/lib/python3.6/enum.py in __call__(cls, value, names, module, qualname, type, start)
    291             return cls.__new__(cls, value)
    292         # otherwise, functional API: we're creating a new Enum type
--> 293         return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
    294 
    295     def __contains__(cls, member):

~/lib/python3.6/enum.py in _create_(cls, class_name, names, module, qualname, type, start)
    382         if isinstance(names, str):
    383             names = names.replace(',', ' ').split()
--> 384         if isinstance(names, (tuple, list)) and isinstance(names[0], str):
    385             original_names, names = names, []
    386             last_values = []

IndexError: list index out of range
History
Date User Action Args
2017-06-09 17:30:17Gerrit.Hollsetrecipients: + Gerrit.Holl
2017-06-09 17:30:17Gerrit.Hollsetmessageid: <1497029417.9.0.731294800985.issue30616@psf.upfronthosting.co.za>
2017-06-09 17:30:17Gerrit.Holllinkissue30616 messages
2017-06-09 17:30:17Gerrit.Hollcreate