Getting exceptions back from calls to embedded python

J

john.pye

Hi all,

I have an application that is using embedded python to offer some
scripting ability. An API is exposed via SWIG, and I am accessing that
API from my embedded python interpreter.

Scripts are present as separate files, and I'm invoking them at present
using the following:

iserr = PyRun_AnyFileEx(f,name,1);

if(iserr){
/* tell the user */
return 1;
}else{
/* all good */
return 0;
}

My question is, if I want to be able to get information about
exceptions that have occurred here (perhaps a syntax error, or an
import error, or perhaps a runtime error), what would be the easiest
way to do this now?

I understand that I'm currently using the 'very high level interface'
for python embedding. What's the easiest next step down that will allow
me to catch exceptions and report them?

Would appreciate any thoughts.

Cheers
JP
 
G

Gabriel Genellina

At said:
I have an application that is using embedded python to offer some
scripting ability. An API is exposed via SWIG, and I am accessing that
API from my embedded python interpreter.

Scripts are present as separate files, and I'm invoking them at present
using the following:

iserr = PyRun_AnyFileEx(f,name,1);

if(iserr){
/* tell the user */
return 1;
}else{
/* all good */
return 0;
}

My question is, if I want to be able to get information about
exceptions that have occurred here (perhaps a syntax error, or an
import error, or perhaps a runtime error), what would be the easiest
way to do this now?

I understand that I'm currently using the 'very high level interface'
for python embedding. What's the easiest next step down that will allow
me to catch exceptions and report them?

I can't verify it right now, but I think that the PyRun_File* family
would let you call PyErr_Occurred and related functions afterwards.


--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top