Ticket #140 (assigned defect)

Opened 2 years ago

Last modified 2 years ago

IPythonShellEmbed() disturbs regular (embedded) Python traceback

Reported by: fperez Assigned to: fperez (accepted)
Priority: normal Milestone: 0.9.0
Component: ipython Version:
Severity: normal Keywords:
Cc:

Description

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')" );
            // 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.

Change History

04/03/07 01:01:24 changed by fperez

  • status changed from new to assigned.
  • milestone changed from 0.7.4 to 0.9.0.