Issue 1583276: Different behavior when stepping through code w/ pdb (original) (raw)
The attached test case will raise a NameError when executed in pdb by stepping though the code. The issue is the EnumType name, which is both a local variable in the Enum function which is used in the lambda and the name of an attribute on the EnumValue class. Since it is a local variable used in a lambda, it's a freevar. What apparently happens is on line 5 the property() result is stored in frame->f_locals['EnumType'] but it is deleted the next time FastToLocals is invoked prior to calling back into the debugger. This happens when the freevars values are merged into the locals dictionary.
The example is a stripped down version of code in turbogears.