-
Notifications
You must be signed in to change notification settings - Fork 2.2k
returning Python list of wrapped non-copyable type #1766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It seems that the problem lies here:
inline handle object_or_cast(PyObject *ptr) { return ptr; }
template <typename T, enable_if_t<!is_pyobject<T>::value, int>>
object object_or_cast(T &&o) { return pybind11::cast(std::forward<T>(o)); }
template <typename T, enable_if_t<is_pyobject<T>::value, int> = 0>
auto object_or_cast(T &&o) -> decltype(std::forward<T>(o)) { return std::forward<T>(o); }
// C++ type -> py::object
template <typename T, detail::enable_if_t<!detail::is_pyobject<T>::value, int> = 0>
object cast(const T &value, return_value_policy policy = return_value_policy::automatic_reference,
handle parent = handle()) {
if (policy == return_value_policy::automatic)
policy = std::is_pointer<T>::value ? return_value_policy::take_ownership : return_value_policy::copy;
else if (policy == return_value_policy::automatic_reference)
policy = std::is_pointer<T>::value ? return_value_policy::reference : return_value_policy::copy;
return reinterpret_steal<object>(detail::make_caster<T>::cast(value, policy, parent)); // calls type caster
} type caster has multiple overloads, including |
Thanks for the detailed report, but this is already fixed on master. #1260 |
Issue description
Returning a list of non copyable type raises an exception. This should not happen.
Reproducible example code
How can I return a list of objects that are not copyable? This looks like a bug to me.
The text was updated successfully, but these errors were encountered: