[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-22 Thread Roundup Robot
Roundup Robot added the comment: New changeset ed011b0d7daf by Ethan Furman in branch 'default': Close #19025: Better error message when trying to delete an Enum member. http://hg.python.org/cpython/rev/ed011b0d7daf -- nosy: +python-dev resolution: -> fixed stage: -> committed/rejected

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-22 Thread Ethan Furman
Ethan Furman added the comment: Okay, I changed my mind about __delattr__. Having it say "AttributeError: cannot delete Enum member" is certainly nicer than "AttributeError: MemberName" -- ___ Python tracker

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-15 Thread Vajrasky Kok
Vajrasky Kok added the comment: Here is the patch containing unit test only to confirm existing behaviour. So people can learn what to expect when they delete Enum attributes. Even if we *decide* to change the behaviour of "del MyPet.CUTE_CAT" (assuming CUTE_CAT is an Enum member), I sense tha

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-15 Thread Ethan Furman
Ethan Furman added the comment: As for the error messages (going in reverse order): == --> del cute_cat.name Traceback (most recent call last): ... AttributeError: can't delete attribute =

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-15 Thread Ethan Furman
Ethan Furman added the comment: Perhaps a section in the docs about the differences from typical Python classes is warranted: - Enum members are virtual - Enum members are singletons - new Enum members (aka instances of an Enum class) cannot be created - during class creation Enum membe

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-15 Thread Ethan Furman
Changes by Ethan Furman : -- assignee: -> ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-15 Thread Barry A. Warsaw
Changes by Barry A. Warsaw : -- nosy: +barry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-15 Thread R. David Murray
R. David Murray added the comment: Doesn't this confusion (here and in 19011) arise from the fact that the enum class does *not* have CUTE_CAT attribute? That is, the error message is correct, but surprising. Because, frankly, Enums are surprising in many ways ;) -- nosy: +r.david.mu

[issue19025] Deleting attribute of Enum gives misleading error message

2013-09-15 Thread Vajrasky Kok
New submission from Vajrasky Kok: >>> from enum import Enum >>> class MyPet(Enum): ... CUTE_CAT = 1 ... VIGOROUS_DOG = 2 ... UGLY_BLOBFISH = 3 ... PROMISCUOUS_BONOBO = 4 ... def spam(cls): pass ... >>> del MyPet.CUTE_CAT Traceback (most recent call last): File "", line 1, in Attribu