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.
This commit is contained in:
Trygve Laugstøl 2016-08-01 08:45:16 +02:00
parent f38f359f96
commit 3572bc3e82

View File

@ -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();
}
}