[ python-Bugs-861340 ] UnboundLocalError in cgitb.py

SourceForge.net noreply at sourceforge.net
Thu Dec 18 10:02:08 EST 2003


Bugs item #861340, was opened at 2003-12-16 18:09
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=861340&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
>Assigned to: Skip Montanaro (montanaro)
Summary: UnboundLocalError in cgitb.py

Initial Comment:
Here's the exception: 
 
Exception 
    return cgitb.text((E, e, tb)).rstrip('\r\n') 
  File "/usr/lib/python2.3/cgitb.py", line 197, in text 
    vars = scanvars(reader, frame, locals) 
  File "/usr/lib/python2.3/cgitb.py", line 76, in scanvars 
    parent = value 
UnboundLocalError: local variable 'value' referenced 
before assignment 
 
And here's the code: 
 
            if lasttoken == '.': 
                if parent is not __UNDEF__: 
                    value = getattr(parent, token, __UNDEF__) 
                    vars.append((prefix + token, prefix, value)) 
            else: 
                where, value = lookup(token, frame, locals) 
                vars.append((token, where, value)) 
        elif token == '.': 
            prefix += lasttoken + '.' 
            parent = value 
 
If lasttoken is '.' and parent is __UNDEF__, value doesn't 
get set.  I'd offer a patch, but I really have no idea what this 
code is doing and so don't know what to set value to. 

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-12-18 10:02

Message:
Logged In: YES 
user_id=33168

Jeremy, can you attach a complete test case?

Skip, I realize you didn't write the scanvars code (Ping
did), but you did add text.  So maybe you have an idea. 
>From a brief scan, it looks like if value is initialized to
None, the code might work.  

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

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



More information about the Python-bugs-list mailing list