Failure to handle enum objects in 'Stack Data' correctly
I have a case where the stack data does not show the correct value for a variable, this is the enum.Enum and enum.IntEnum classes. I am using them to replace magic numbers which would otherwise be needed.
This can be reproduced in more recent versions of Python (3.4.3, 3.5.0) by having a small test module containing the following:
If you run this through the debugger, you'll see in the stack data window that the value of 'mode' is given as Enum.MetaData, whilst the value of 'lock' is shown as None. If you hover the cursor over the variables then the correct value is shown (ie OpenMode.ISINPUT or LockMode.ISAUTOLOCK).
I believe that the enum.IntEnum derived classes will always show None, and that the enum.Enum derived classes show Enum.MetaData.
This is not a show stopper but did cause me to double check the code was correct just to be certain, and I thought it would be good to provide a "heads up" in case someone else encounters the issue.
Re: Failure to handle enum objects in 'Stack Data' correctly
Richard Moseley via wingide-users wrote:
> import enum
> class OpenMode(enum.Enum):
> ISINPUT = 0x000
> ISOUTPUT = 0x001
> ISINOUT = 0x002
> class LockMode(enum.IntEnum):
> ISAUTOLOCK = 0x200
> ISMANULOCK = 0x400
> ISEXCLLOCK = 0x800
> mode = OpenMode.ISINPUT
> lock =LockMode.ISAUTOLOCK
> If you run this through the debugger, you'll see in the stack data
> window that the value of 'mode' is given as Enum.MetaData, whilst the
> value of 'lock' is shown as None. If you hover the cursor over the
> variables then the correct value is shown (ie OpenMode.ISINPUT or
Thanks, it looks like Stack Data is trying to show the complete contents
of these instances in a probably non-useful way (and apparently failing
entirely for intEnums). As you noted hovering over them in the editor
shows the right value, and you can also type their names in Debug Probe
to see the correct values.
We'll look into fixing this.
Wingware | Python IDE
The Intelligent Development Environment for Python Programmers