[issue43162] Enum regression: AttributeError when accessing class variables on instances

Ethan Furman report at bugs.python.org
Mon Feb 8 20:43:24 EST 2021


Ethan Furman <ethan at stoneleaf.us> added the comment:

Dylan, it's not the `from_str()` method, but the `__str__` method that is the problem.  Instead of

    def __str__(self):
        if self is self.EXITCODE: 
            return 'exitcode' 

it should be

    def __str__(self):

        cls = self.__class__

        if self is cls.EXITCODE: 
            return 'exitcode'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43162>
_______________________________________


More information about the Python-bugs-list mailing list