pybind11
pybind11 copied to clipboard
docs: fix error condition in custom type caster example
Description
I found a mistake in the documentation for custom type_casters, which I believe hasn't been covered by an open issue or PR yet. The load function of a type caster struct is supposed to return true upon success. However, the condition
!(value.long_value == -1 && !PyErr_Occurred())
whose value is returned, evaluates to false if no error occurred and the Python float value is -1. The negation of the result of PyErr_Occurred() needs to be removed.
Suggested changelog entry:
* Fixed the return value in the custom type caster example
This PR should be resolved by #5450 since the example was completely changed.