[C++-sig] Re: Calling a python function from C++ (from Jeff Holle)

Jeff Holle jeff.holle at verizon.net
Tue Jun 29 12:22:37 CEST 2004


>
>
>> An underlining concern I have is error handling.  When
>> PyImport_ImportModule fails, a NULL pointer is returned.
>> Seems like the underlining machinery in "handle<>" is intolerant of
>> this. 
>  
>
>
>What makes you say that?
>
You are correct about the success in compiling your much cleaner 
example, and it works :-) , but has a flaw.

When I hide the needed python script, the call to PyImport_ImportModule 
returns NULL.
When this occurres, both your example and what I had created, but 
commented out throws something because I can catch it with 
"catch(...)".  I don't however know how to be more specific.  Any 
hints?  Whatever it is, it doesn't inherit from "exception".

If I was operating on windows, I would anticipate it was a "structured 
exception", or whatever Microsoft calls their propritary stuff.  Don't 
know of the equivalent on linux though.  Without the "catch (...)", the 
command line program exits with "Aborted".







More information about the Cplusplus-sig mailing list