Add __prepare__() to allow Python >= 3.3 to check for unique attribute names

Bug #1167049 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

E.g. this should be an error in >= Python 3.3:

class X(Enum):
    a = 1
    b = 2
    a = 3

and also:

X = Enum('X', [('a', 1), ('b', 2), ('a', 3)])

There's no good way to do this in earlier Pythons though.

Revision history for this message
Barry Warsaw (barry) wrote :

After further thought and with Eli's feedback: the class syntax shouldn't raise an exception. This is just the way Python works, so we should leave that alone. The convenience API *could* do an extra check, but it doesn't seem worth being different here, so for now, I won't change this.

Changed in flufl.enum:
status: New → Won't Fix
status: Won't Fix → Triaged
status: Triaged → 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.