[IPython-user] Problem with IPShellEmbed
Fernando.Perez at colorado.edu
Tue Feb 1 00:10:22 CST 2005
Michael Foord wrote:
> Hmm... I've got to the bottom of the problem I had with IPShellEmbed.
> When I made the change suggested - (`frame = sys._getframe(1)`) which
> didn't stop the crash but revealed a more helpful error message.
> Traceback (most recent call last):
> File "movpy.py", line 921, in ?
> File "movpy.py", line 551, in interactive
> File "IPython\Shell.pyo", line 133, in __init__
> File "IPython\ipmaker.pyo", line 82, in make_IPython
> File "IPython\iplib.pyo", line 602, in __init__
> File "IPython\Itpl.pyo", line 227, in itpl
> File "IPython\Itpl.pyo", line 184, in __str__
> File "psyco\support.pyo", line 120, in __getattr__
> AttributeError: local variables of functions run by Psyco cannot be
> accessed in any way, sorry
> Basically IPython doesn't play nicely with psyco (psyco hides local
> variables in functions it's covering).
> As an experiment try typing ``import pscyo; psyco.full()`` at an IPython
> command line ! (I *do* get the same result in Python 2.3 and Python 2.4)
OK, I can understand why psyco does that, but it means it's going to be a bit
unpleasant to make ipython and psyco play well together. It will take a bit
of trial and error to identify all the potential breakdown points, and then
they will need to be wrapped in appropriate exception traps.
I've been looking at your traceback, and it turns out ipython uses itpl()
calls in quite a few places, and Itpl.itpl() relies on _getframe tricks. In a
few places, I could probably replace the itpl calls with plain string
interpolations, the cost is just a clumsier syntax. But there are places
where avoiding Itpl altogether would probably require a much deeper rewrite,
and I'm not even 100% sure it's possible to get to all the functionality of
ipython without some stack tricks. IPython really has to be able to manage a
clean stack to provide much of its user-visible power, and with a
psyco-mangled one, it's going to be rough going.
I've put up in the testing dir:
a 0.6.11_cvs source tarball which you can try and use. I've hardened things
in a few places to try to survive against psyco's stack mangling, but it's not
guaranteed to work.
Let me know how it goes.
More information about the IPython-user