| 454 | |
| 455 | template <typename T> |
| 456 | static handle cast(T &&src, return_value_policy policy, handle parent) { |
| 457 | list l(src.size()); |
| 458 | ssize_t index = 0; |
| 459 | for (auto &&value : src) { |
| 460 | auto value_ = reinterpret_steal<object>( |
| 461 | value_conv::cast(detail::forward_like<T>(value), policy, parent)); |
| 462 | if (!value_) { |
| 463 | return handle(); |
| 464 | } |
| 465 | PyList_SET_ITEM(l.ptr(), index++, value_.release().ptr()); // steals a reference |
| 466 | } |
| 467 | return l.release(); |
| 468 | } |
| 469 | |
| 470 | // Code copied from PYBIND11_TYPE_CASTER macro. |
| 471 | // Intentionally preserving the behavior exactly as it was before PR #5305 |