[docs] [issue17947] Code, test, and doc review for PEP-0435 Enum

Eli Bendersky report at bugs.python.org
Sat May 11 21:10:46 CEST 2013

Eli Bendersky added the comment:

Ethan, something is wrong with _StealthProperty. Well, two things. First, it's way too general and can be cut to just what Enum needs. Second, this is enough to make the tests pass:

class _StealthProperty():
    Returns the value in the instance, or the virtual attribute on the class.

    A virtual attribute is one that is looked up by __getattr__, as opposed to
    one that lives in __class__.__dict__


    def __init__(self, fget):
        self.fget = fget

    def __get__(self, obj, objtype=None):
        return self.fget(obj)

    def __set__(self, obj, value):
        raise AttributeError("can't set attribute")

    def __delete__(self, obj):
        raise AttributeError("can't delete attribute")

Now  this is fishy because __get__ gets obj=None when called on a class and therefore self.fget(obj) raises an exception. But this gets caught somewhere in your code or tests and ignored. However, the right thing is still returned. I didn't have more time to investigate, but this must be cleaned out.


Python tracker <report at bugs.python.org>

More information about the docs mailing list