pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

docs: fix error condition in custom type caster example

Open gschnabel opened this issue 1 year ago • 1 comments

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

gschnabel avatar Oct 21 '24 12:10 gschnabel

This PR should be resolved by #5450 since the example was completely changed.

timohl avatar Dec 09 '24 14:12 timohl