mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
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:
parent
f38f359f96
commit
3572bc3e82
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user