Open
Description
We disable copying and moving (not that moving is relevant here) for a set of virtual classes, because we would like to have a compile-time guarantee that we are not slicing classes. This generally has no issue in pybind
, until callbacks are used, in which case the const T&
instance may not be registered, and thus pybind
tries to copy it, and then throws a runtime error.
Potential solutions:
- Specify callback arguments' return-value-policies (per @jagerman's suggestion) when casting a function.
- Modify the
type_caster_base::cast(const T&)
to check forautomatic
and if the class is non-copyableand non-movable, default toreference
rather thancopy
.- This seems like it might be backwards-incompatible, but possibly not (as copying would be unsuccessful anyways).
My workaround for the time being will be to wrap any callbacks (Python callbacks cast into std::function<...>
) that have const T&
references to use const T*
instead.
Metadata
Metadata
Assignees
Labels
No labels