Add __prepare__() to allow Python >= 3.3 to check for unique attribute names
Bug #1167049 reported by
Barry Warsaw
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.
To post a comment you must log in.
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.