[Python-bugs-list] [ python-Bugs-549038 ] cgitb variable dumps a little flaky

noreply@sourceforge.net noreply@sourceforge.net
Sat, 02 Nov 2002 19:28:26 -0800


Bugs item #549038, was opened at 2002-04-26 08:11
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=549038&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: Works For Me
Priority: 5
Submitted By: Jon Ribbens (jribbens)
Assigned to: Ka-Ping Yee (ping)
Summary: cgitb variable dumps a little flaky

Initial Comment:
First off, easy problem: lookup() should look in 
frame.f_globals["__builtins__"] also. Along the same 
lines, I am not sure if lookup works properly with 
nested scopes, but since I don't use nested scopes in 
any of my code this is not a problem for me ;-)

Secondly, the parsing in scanvars() is somewhat hacky. 
For example, given the following line:

  foo(open(filename).read())

it will think the following variables exist:

  foo
  open
  filename
  ).read

Obviously this last one is incorrect. I am not sure if 
this is easy to fix or not.


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-11-02 22:28

Message:
Logged In: YES 
user_id=33168

Jon, is this fixed?  Can it be closed?  If not, what do you
think needs to be done?

----------------------------------------------------------------------

Comment By: Jon Ribbens (jribbens)
Date: 2002-06-26 06:28

Message:
Logged In: YES 
user_id=76089

I'm not quite sure why you were unable to reproduce 
the ").read" bit. Try the following code:

import cgitb; cgitb.enable()
filename = "foo"
foo(open(filename).read())

The output includes:

foo undefined, open undefined, filename = 'foo', ).read 
undefined

Do you get something different?

----------------------------------------------------------------------

Comment By: Ka-Ping Yee (ping)
Date: 2002-06-26 03:11

Message:
Logged In: YES 
user_id=45338

The lookup function looks in frame.f_locals, which does the right thing 
with respect to nested scopes as far as i can tell.

I tested the parser and wasn't able to reproduce the problem you described. 

Thanks for the bug report.  I have committed a change that adds the 
lookup in __builtins__.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-28 20:50

Message:
Logged In: YES 
user_id=6380

Nobody except Ka-Ping Ping understands the code in cgitb.py,
so I suggest that you track him down and get him to look at
this bug report. In the past I've performed this service
myself but I'm getting tired of it.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=549038&group_id=5470