[IPython-user] Problem with IPShellEmbed
mike at pcblokes.com
Fri Jan 28 06:25:05 CST 2005
Fernando Perez wrote:
> Michael Foord wrote:
>> I've encountered a problem with IPShellEmbed, for my Movable Python
>> project. It's quite likely that this problem is my fault - but I
>> would still appreciate help ! It looks like a frame object is
>> expected and None is returned.
>> Basically *sometimes* a call to IPShellEmbed will fail :
>> ipshell = IPShellEmbed(argv, banner=banner)
>> The error raised occurs in :
>> File "C:\Python24\Lib\site-packages\IPython\Itpl.py", line 182, in
>> while frame.f_globals["__name__"] == __name__: frame = frame.f_back
>> AttributeError: 'NoneType' object has no attribute 'f_globals'
> Very, very strange. It seems like you have a stack with a bogus frame
> somewhere. Here's something to try: in the Itpl.py file, around line
> 182, comment out 3 lines and add a _getframe as follows:
Ha -and another thing, it only seems to happen with python 2.4..
I've attempted to reproduce the problem at work on a machine with Python
2.3. I don't see the same problem.... I can *definitely* only confirm
this later - when I get a chance to test again under Python 2.4.
> def __str__(self):
> """Evaluate and substitute the appropriate parts of the
> ## try: 1/0
> ## except: frame = sys.exc_traceback.tb_frame
> ## while frame.f_globals["__name__"] == __name__: frame =
> frame = sys._getframe(1) ##### <<<--- NEW LINE HERE
> loc, glob = frame.f_locals, frame.f_globals
> This should pull the caller's frame correctly. Itpl was originally
> written before sys._getframe existed, so it used the 1/0 trick. If
> this fixes your problem, I'll add it for the next release.
> Let me know what happens.
More information about the IPython-user