Uh oh!
There was an error while loading. Please reload this page.
Fixing SystemError when nb_bool/nb_nonzero sets a Python exception in type_caster<bool>::load - #1976
Conversation
… type_caster<bool>::load
(Thanks to @tdegeus for reporting on Gitter and sticking along while debugging, btw!) |
OK, this is because Ready to merge, as far as I'm concerned, then! |
tdegeus
commented
Nov 1, 2019
Thanks @YannickJadoul ! |
wjakob
commented
Nov 1, 2019
What strikes me as odd about this PR is why this is something specific to the |
@wjakob The main problem is calling into the C API without checking the result (i.e., if it's When other casters call into the C API, they do check the result for errors and clear if necessary. For example: integer-types caster, pybind11/include/pybind11/cast.h Line 1024 in a6355b0
pybind11/include/pybind11/cast.h Line 1219 in a6355b0 |
wjakob
commented
Nov 14, 2019
Ok, fair enough -- merged, thanks! |
… type_caster<bool>::load (#1976)
YannickJadoul
commented
Nov 14, 2019
The two Travis CI jobs are failing because something ( |
If the error indicator is set by a failing conversion in
type_caster<bool>::load(e.g., by trying to convert anumpy.ndarrayof 2 or more values, resulting inValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()), the error is not noticed and Python complains that a non-NULL value is returned while an error has been set (SystemError: [...] returned a result with an error set).This PR should fix that.
NOTE: Without the changes to
cast.h, the newly added test fails:Is that not unexpected as well? Shouldn't all
error_already_setexceptions be caught by pybind11?