handle errors in callbacks

This commit is contained in:
Wenzel Jakob 2015-09-11 17:01:21 +02:00
parent 5116b02e68
commit 38ffb5232f

View File

@ -25,6 +25,8 @@ public:
object src(src_, true); object src(src_, true);
value = [src](Args... args) -> Return { value = [src](Args... args) -> Return {
object retval(pybind::handle(src).call(std::move(args)...)); object retval(pybind::handle(src).call(std::move(args)...));
if (retval.ptr() == nullptr && PyErr_Occurred())
throw error_already_set();
/* Visual studio 2015 parser issue: need parentheses around this expression */ /* Visual studio 2015 parser issue: need parentheses around this expression */
return (retval.template cast<Return>()); return (retval.template cast<Return>());
}; };