[IPython-user] Problem with IPShellEmbed
Michael Foord
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
>> __str__
>> 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.
Regards,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
>
> def __str__(self):
> """Evaluate and substitute the appropriate parts of the
> string."""
>
> ## try: 1/0
> ## except: frame = sys.exc_traceback.tb_frame
>
> ## while frame.f_globals["__name__"] == __name__: frame =
> frame.f_back
>
> 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.
>
> Cheers,
>
> f
>
>
>
More information about the IPython-user
mailing list