Getting exceptions back from calls to embedded python

john.pye at gmail.com john.pye at gmail.com
Wed Nov 22 14:00:52 CET 2006


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




More information about the Python-list mailing list