Closed
Description
Issue description
Returning a list of non copyable type raises an exception. This should not happen.
Reproducible example code
#include <pybind11/pybind11.h>
struct non_copyable
{
non_copyable() = default;
non_copyable(const non_copyable&) = delete;
non_copyable& operator=(non_copyable) = delete;
non_copyable(non_copyable&&) = default;
non_copyable& operator=(non_copyable&&) = default;
};
PYBIND11_MODULE(test_mod, m)
{
py::class_<non_copyable>(m, "NonCopyable")
.def(py::init());
m.def("get_list", []()
{
py::list list;
list.append(non_copyable());
list.append(non_copyable());
return list;
});
}
import test_mod
l = test_mod.get_list()
RuntimeError: return_value_policy = copy, but the object is non-copyable!
How can I return a list of objects that are not copyable? This looks like a bug to me.
Metadata
Metadata
Assignees
Labels
No labels