handle errors in callbacks

This commit is contained in:
Wenzel Jakob 2015-09-11 17:01:21 +02:00
parent 5116b02e68
commit 38ffb5232f
1 changed files with 2 additions and 0 deletions

View File

@ -25,6 +25,8 @@ public:
object src(src_, true);
value = [src](Args... args) -> Return {
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 */
return (retval.template cast<Return>());
};