Original report:
From: "Remy X.O. Martin" <rmvsxop at gmail.com>
Date: Sat, 30 Sep 2006 15:13:24 +0200
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')" );
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...?!
End of original report.
See
http://lists.ipython.scipy.org/pipermail/ipython-dev/2006-October/002425.html
for the email report and possible replies.