Bug in inspect.py for python 2.3?
tjreedy at udel.edu
Fri Dec 17 19:02:53 EST 2004
"Fernando Perez" <fperez528 at yahoo.com> wrote in message
news:cpvmrl$501$1 at sea.gmane.org...
> I'd like to hear from some of our resident gurus if this is really an
> inspect.py bug before I bother the developers with a formal bug report on
I know nothing of inspect, but this certainly look like a bug (see below).
> #!/usr/bin/env python
> """This script triggers an exception in inspect.py"""
> import sys
> import inspect
> # This line is invalid, but we should be able to build exception info
> # it with the usual tools.
> (lambda(x): x + x)(3)
> etb = sys.exc_info()
> records = inspect.getinnerframes(etb)
> for frame, file, lnum, func, lines, index in records:
> # The getargvalues call below blows up with an exception in
> args, varargs, varkw, locals = inspect.getargvalues(frame)
> print 'args:',args
[I removed the blank lines which made it diffificult to cut and paste.]
[Here is the output (from 2.2) you forgot to include'-):]
Traceback (most recent call last):
File "<stdin>", line 9, in ?
File "C:\Python22\lib\inspect.py", line 629, in getargvalues
args, varargs, varkw = getargs(frame.f_code)
File "C:\Python22\lib\inspect.py", line 592, in getargs
remain[-1] = remain[-1] - 1
IndexError: list index out of range
Error happens on second iteration. Getargs seems to be trying to index
into an empty list, which it either should not do or should wrap with
If the same happens in 2.4, I would probably report it after looking a bit
at the inspect code and after adding a debug print before the getargvalues
call to see if the second record values looks as sane as the first set. If
you want a fix in 2.3.5, coming January, a patch would more likely get
action than just a bug report.
Terry J. Reedy
More information about the Python-list