[IPython-dev] [FWD] IPythonShellEmbed() disturbs regular (embedded) Python traceback
Fernando Perez
Fernando.Perez at colorado.edu
Sat Oct 28 14:15:40 EDT 2006
Forwarded to the list, please note that you need to be subscribed to post (we
get way too much spam otherwise).
I'll reply on-list, sorry for the delay, this slipped in a pile of other email.
Cheers,
f
# ORIGINAL MESSAGE:
Subject:
IPythonShellEmbed() disturbs regular (embedded) Python traceback
From:
"Remy X.O. Martin" <rmvsxop at gmail.com>
Date:
Sat, 30 Sep 2006 15:13:24 +0200
To:
ipython-dev at scipy.org
Hello,
I am embedding Python in one of my C apps, and use IPythonShellEmbed
to support an interactive Python shell, using
if( !called ){
PyRun_SimpleString( "from IPython.Shell import IPythonShellEmbed" );
PyRun_SimpleString( "xgraph.ipshell=IPythonShellEmbed()" );
PyRun_SimpleString( "xgraph.ipshell.set_banner('Entering
xgraph.ipshell IPython shell')" );
PyRun_SimpleString( "xgraph.ipshell.set_exit_msg('Leaving
xgraph.ipshell IPython shell')" );
// Not clear if this is needed or actually does anything:
PyRun_SimpleString( "xgraph.ipshell.restore_system_completer()" );
called= 1;
}
If I call this upon initialising the embedded interpreter, (some)
syntax errors in user code no longer generate useful error messages:
def RedrawNow:
return None
---------------------------------------------------------------------------
None Traceback (most recent call last)
None: None
If I do *not* initialise the interactive shell, I get the usual message
def RedrawNow:
return None
File "<string>", line 1
def RedrawNow:
^
SyntaxError: invalid syntax
This is of course quite annoying: execution of the Python code stops
at the offending statement, but there is no way to find out what that
statement was.
To be honest, I don't see why IPython would become active outside an
eventual call to xgraph.ipshell() as defined above...?!
Regards,
R.M.
More information about the IPython-dev
mailing list