getattr syntax should support enum value as argument

Bug #1124596 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
flufl.enum
Fix Released
Wishlist
Barry Warsaw

Bug Description

This should be legal:

>>> from flufl.enum import make
>>> Colors = make('Colors', 'red green blue'.split())
>>> Colors[Colors.red]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flufl/enum/_enum.py", line 92, in __getitem__
    return getattr(cls, i)
TypeError: getattr(): attribute name must be string

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/flufl/enum/_enum.py", line 94, in __getitem__
    raise ValueError(i)
ValueError: Colors.red

Barry Warsaw (barry)
Changed in flufl.enum:
milestone: none → 3.4
assignee: nobody → Barry Warsaw (barry)
status: New → In Progress
Barry Warsaw (barry)
Changed in flufl.enum:
status: In Progress → Triaged
milestone: 3.4 → none
Barry Warsaw (barry)
Changed in flufl.enum:
milestone: none → 3.4
status: Triaged → Fix Committed
Barry Warsaw (barry)
Changed in flufl.enum:
status: Fix Committed → Fix Released
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.