[Ipython-tickets] [IPython] #140: IPythonShellEmbed() disturbs regular (embedded) Python traceback

IPython ipython-tickets@scipy....
Tue Apr 3 00:50:49 CDT 2007


#140: IPythonShellEmbed() disturbs regular (embedded) Python traceback
---------------------+------------------------------------------------------
 Reporter:  fperez   |       Owner:  fperez
     Type:  defect   |      Status:  new   
 Priority:  normal   |   Milestone:  0.7.4 
Component:  ipython  |     Version:        
 Severity:  normal   |    Keywords:        
---------------------+------------------------------------------------------
 Original report:

 From: "Remy X.O. Martin" <rmvsxop at gmail.com>[[BR]]
 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
 {{{
 #!C
       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...?!


 End of original report.
 ----

 See

 http://lists.ipython.scipy.org/pipermail/ipython-
 dev/2006-October/002425.html

 for the email report and possible replies.

-- 
Ticket URL: <http://projects.scipy.org/ipython/ipython/ticket/140>
IPython <http://ipython.scipy.org>
The IPython interactive Python system


More information about the Ipython-tickets mailing list