Failure to handle enum objects in 'Stack Data' correctly

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Failure to handle enum objects in 'Stack Data' correctly

WingIDE - User mailing list
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:

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

Richard Moseley


_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Failure to handle enum objects in 'Stack Data' correctly

WingIDE - User mailing list
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
> LockMode.ISAUTOLOCK).

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.

Thanks again,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com


_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide