__value_factory__ should be added when the default is used

Bug #1172870 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
flufl.enum
Won't Fix
Undecided
Unassigned

Bug Description

It should always be possible to get the item factory for an enum through the __value_factory__ attribute (or whatever we end up calling it in the end). It's possible when given explicitly, as is the case for IntEnum:

>>> A = IntEnum('A', 'a b c')
>>> A.__value_factory__
<class 'flufl.enum._enum.IntEnumValue'>

but not if the default is used.

>>> B = Enum('B', 'a b c')
>>> B.__value_factory__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'B' has no attribute '__value_factory__'

When the default is used, we should add this attribute.

Barry Warsaw (barry)
Changed in flufl.enum:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.