[IPython-dev] [FWD] IPythonShellEmbed() disturbs regular (embedded) Python traceback

Fernando Perez fperez.net at gmail.com
Tue Apr 3 01:51:34 EDT 2007


Hi Remy,

> # ORIGINAL MESSAGE:

> 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...?!


Sorry for the ridiculously long delay, this had just fallen to the
bottom of my pile...

Unfortunately I have to admit I don't know at this moment what the
problem is.  But in order to ensure that we don't lose track of this
problem again, I made a ticket on it:

http://projects.scipy.org/ipython/ipython/ticket/140

Feel free to let us know if you have any thoughts on the solution.

Regards,

f



More information about the IPython-dev mailing list