diff --git a/include/pybind/functional.h b/include/pybind/functional.h index 7c3c9a006..f300d4d4d 100644 --- a/include/pybind/functional.h +++ b/include/pybind/functional.h @@ -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()); };