From 3572bc3e825c9ff2ee67942dfb4f9edb4cf30da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trygve=20Laugst=C3=B8l?= Date: Mon, 1 Aug 2016 08:45:16 +0200 Subject: [PATCH] Changes accessor::operator=() to throw error_already_set() instead of using pybind11_fail(). PyObject_SetItem and PyObject_SetAttr both throws an exception on failure so this will show the underlying exception instead of masking it. Fixes #303. --- include/pybind11/pytypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index d0248079d..c8a90f871 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -117,10 +117,10 @@ public: void operator=(const handle &value) { if (attr) { if (PyObject_SetAttr(obj.ptr(), key.ptr(), value.ptr()) == -1) - pybind11_fail("Unable to set object attribute"); + throw error_already_set(); } else { if (PyObject_SetItem(obj.ptr(), key.ptr(), value.ptr()) == -1) - pybind11_fail("Unable to set object item"); + throw error_already_set(); } }