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
==========================================================================

This is the same error given by @property.


==========================================================================
--> del MyPet.spam
--> hasattr(MyPet, 'spam')
False
==========================================================================

This is correct.  Only Enum members get special treatment.


==========================================================================
--> del MyPet['LONELY_WOLF']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'EnumMeta' object does not support item deletion
==========================================================================

There are two errors here: LONELY_WOLF does not exist, and an operation is 
being attempted that is not supported.  Of those two, attempting the 
unsupported operation is the more serious, and should be the reported error.  
(Yes, dealing with multiple errors at once can often be confusing.)


==========================================================================
--> del MyPet.CUTE_CAT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: CUTE_CAT
==========================================================================

This one I am not sure about (much as I am not sure about __getattr__ in 
#19011).  Enum members are virtual, and don't actually live in the class 
namespace.  I'm inclined to leave the existing behavior as is, but if we choose 
to change one, we should change both.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to