[I posted this on StackOverflow yesterday, but got nothing. Hoping you will
have some insight!]
I'm writing a C++ python extension. I have a boost::python extension function
static void EXTrender_effect(EffectGlobals_t *effect_handle,
std::string preset,
bp::object dest, int xdim, int ydim)
{ ... }
that I export as usual in my boost.python extension:
def("render_effect", EXTrender_effect);
When I call that from python(2.7), I get a C++ exception
boost::python::error_already_set. Tracing that down in Visual Studio, I can see
it's coming from a boost::python::objects::function::argument_error. So OK, I
have an argument error; I'm probably calling it with the wrong args. What I'd
like to do is print or throw something sensible in my python extension when
this happens, so users of my extension will see the nice message that I know is
lurking in PyErr_Fetch. (I can see the message getting built in the
boost.python argument_error code.)
But I can't catch that error_already_set; boost.python does that internally
around the funcall. And I can't check for python errors in my extension code,
since my function never gets called (the argument error is detected by
boost.python). What ends up happening is it just silently fails.
What can I hook up so I (or my users) can see the argument error messages? And
ideally convert those into python exceptions?
This is all Win7, Python2.7.
--
. . . . . . . . . . . . . . . . . . . . . .
Gary Oberbrunner [email protected]
VP Engineering Tel: 617-492-2888
GenArts, Inc. www.genarts.com
_______________________________________________
Cplusplus-sig mailing list
[email protected]
https://mail.python.org/mailman/listinfo/cplusplus-sig