From 38ffb5232f3fc83b5aeff46b38ebc762fe392e0a Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 11 Sep 2015 17:01:21 +0200 Subject: [PATCH] handle errors in callbacks --- include/pybind/functional.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/pybind/functional.h b/include/pybind/functional.h index 7c3c9a00..f300d4d4 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()); };