Hi all,
IPython has suffered quite a few problems with the inspect module in python
2.3. For these, unfortunately all I've been able to do is guard with
overreaching except clauses, as I had not been able to find small,
reproducible examples to pass on to the devs. But today I got a crash report
from a user and I've been able to replicate this crash with a tiny script
which does not depend on ipython at all.
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 SF.
The script below illustrates the problem. Just run it, and you'll get a
traceback coming from inside inspect.py itself. For now, I've added a guard
in ipython against this failure mode, but it would be nice to fix the problem
at the source if there really is one.
Best,
f
#!/usr/bin/env python
"""This script triggers an exception in inspect.py
This exception was crashing ipython for the input line:
(lambda(x): x[0] + x[1])(3)
when IPython tried to print the traceback for the user. As far as I can tell,
it's a bug in inspect, since for all other kinds of calls of invalid user
input, ipython works fine. But perhaps it's my fault, I'm not sure."""
import sys
import inspect
try:
# This line is invalid, but we should be able to build exception info for
# it with the usual tools.
(lambda(x): x[0] + x[1])(3)
except:
etb = sys.exc_info()[2]
records = inspect.getinnerframes(etb)
for frame, file, lnum, func, lines, index in records:
# The getargvalues call below blows up with an exception in inspect.py
args, varargs, varkw, locals = inspect.getargvalues(frame)
print 'args:',args 2 1602
Fernando Perez wrote: IPython has suffered quite a few problems with the inspect module in python 2.3. For these, unfortunately all I've been able to do is guard with overreaching except clauses, as I had not been able to find small, reproducible examples to pass on to the devs. But today I got a crash report from a user and I've been able to replicate this crash with a tiny script which does not depend on ipython at all.
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 SF. The script below illustrates the problem. Just run it, and you'll get a traceback coming from inside inspect.py itself. For now, I've added a guard in ipython against this failure mode, but it would be nice to fix the problem at the source if there really is one.
That is indeed a bug, and it is fixed as of http://sourceforge.net/tracker/index...70&atid=305470
Minimal example:
[Python 2.3.3] def f(a): pass
.... def g((a)): pass
.... inspect.getargs(f.func_code)
(['a'], None, None) inspect.getargs(g.func_code)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/inspect.py", line 624, in getargs
remain[-1] = remain[-1] - 1
IndexError: list index out of range
[Python 2.4] import inspect def g((a)): pass
.... inspect.getargs(g.func_code)
([['a']], None, None)
By the way, I didn't know that sublists of length one are allowed in a
function's parameter list. Certainly they don't make much sense...
Peter
Peter Otten wrote: Fernando Perez wrote: 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 SF. The script below illustrates the problem. Just run it, and you'll get a traceback coming from inside inspect.py itself. For now, I've added a guard in ipython against this failure mode, but it would be nice to fix the problem at the source if there really is one.
That is indeed a bug, and it is fixed as of http://sourceforge.net/tracker/index...70&atid=305470
Great, many thanks for the info. This way I don't bother the devs with
unnecessary bug triage.
Regards,
f This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hans Georg Krauthaeuser |
last post by:
Dear all,
I have a problem to get the command that has called a function if the
command was given on multiple lines. E.g.:
###################################################
import inspect
...
|
by: Thomas Guettler |
last post by:
Hi,
the line numbers of inspect.getinnerframes are
different from traceback.format_exception.
This results in wrong lines being shown in cgitb.
An example is below.
I looked at the...
|
by: It's me |
last post by:
I discovered the hardway what inspect.isclass() is doing. Consider this no
brainer code:
###
import inspect
class Abc:
def Hello(self):
return
|
by: Benjamin Rutt |
last post by:
I'm trying to learn about introspection in Python. my ultimate goal
is to be able to build a module "text database" of all modules that
are in the sys.path, by discovering all candidate modules...
|
by: elventear |
last post by:
Hello,
I am trying to use someone else's module that makes use of
inspect.getsourcelines. The code was not working for me, so I have
been debugging to see why it is not working. I have reduced...
|
by: Chris Pax |
last post by:
Hello,
I recently been trying to use the inspect module to inspect the
arguments of gtk objects, such as gtk.Button. I tried like this:
inspect.getargspec(gtk.Button.__init__)
and get the...
|
by: Stef Mientki |
last post by:
hello,
I'm not familiar with inspect,
but I get an error (see below) in
getmembers ( wx )
Of course this is bug in wx .
But would you also call this a bug in inspect ?
|
by: Stef Mientki |
last post by:
Gabriel Genellina wrote:
REALLY GREAT !
But this is fully beyond my understanding:
m = getmembers ( wx )
print m
runs fine
print getmembers ( wx )
|
by: rajasankar |
last post by:
Hi,
I am using Jython based application and trying to use inspect.py in the python files.
Here is my code
import inspect,os,sys,pprint,imp
def handle_stackframe_without_leak(getframe):
...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |