Commit 3572bc3e by Trygve Laugstøl

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.
parent f38f359f
...@@ -117,10 +117,10 @@ public: ...@@ -117,10 +117,10 @@ public:
void operator=(const handle &value) { void operator=(const handle &value) {
if (attr) { if (attr) {
if (PyObject_SetAttr(obj.ptr(), key.ptr(), value.ptr()) == -1) if (PyObject_SetAttr(obj.ptr(), key.ptr(), value.ptr()) == -1)
pybind11_fail("Unable to set object attribute"); throw error_already_set();
} else { } else {
if (PyObject_SetItem(obj.ptr(), key.ptr(), value.ptr()) == -1) if (PyObject_SetItem(obj.ptr(), key.ptr(), value.ptr()) == -1)
pybind11_fail("Unable to set object item"); throw error_already_set();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment