[IPython-user] Problem with IPShellEmbed
mike at pcblokes.com
Fri Jan 28 05:31:26 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:
I'll check this out tonight, but won't be able to email the results
until Monday I don't think. I do wonder if psyco is somehow involved.
it's not explicitly imported in my code, but maybe in one of the files
that is being run.
Anyway - I'll try your suggestion. thanks.
> 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