[issue21161] list comprehensions don't see local variables in pdb in python3

Xavier de Gaye report at bugs.python.org
Sat Apr 12 11:28:16 CEST 2014


Xavier de Gaye added the comment:

The runcode() method of InteractiveInterpreter in code.py uses the 'self.locals' dictionary as the 'globals' parameter of the invoked exec() function. And the do_interact() method of Pdb instantiates InteractiveInterpreter with 'locals' as a merge of the current frame's locals and globals dictionary. This explains why the interact command of pdb evaluates sucessfully the generator expression: the generator function object is evaluated by the interpreter in a frame where 'locals' is NULL (see fast_function() in ceval.c) and 'globals' includes now the debugged frame locals dictionary.

So a fix for this problem is to have the default() method of pdb be implemented in the same manner as do_interact() and the runcode() method of InteractiveInterpreter. The attached patch does this.

----------
keywords: +patch
Added file: http://bugs.python.org/file34791/genexp.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21161>
_______________________________________


More information about the Python-bugs-list mailing list