[Python-Dev] pdb and nested scopes

Guido van Rossum guido@digicool.com
Wed, 28 Feb 2001 10:34:52 -0500


> Hi. 
> 
> Sorry if everybody is already aware of this.

No, it's new to me.

> I have checked the code for pdb in CVS , especially for the p cmd,
> maybe I'm wrong but given actual the implementation of things that
> gives no  access to the value of free or cell variables. Should that
> be fixed?

I think so.  I've noted that the locals() function also doesn't see
cell variables:

    from __future__ import nested_scopes
    import pdb
    def f():
	a = 12
	print locals()
	def g(): print a
	g()
	a = 100
	g()
	#pdb.set_trace()
    f()

This prints

    {}
    12
    100

When I enable the pdb.set_trace() call, indeed the variable a is not
found.

> AFAIK pdb as it is works with jython too. So when fixing that, it would
> be nice if this would be preserved.

Yes!

--Guido van Rossum (home page: http://www.python.org/~guido/)