Skip to content

Commit 2c95a39

Browse files
committed
Pass arguments from trampoline methods via return_value_policy::reference
Otherwise, modifications applied by Python-coded method overrides would be applied to copies, even though the parameters were passed by pointer or reference.
1 parent fed0a44 commit 2c95a39

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/pybind11/pybind11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
21792179
pybind11::gil_scoped_acquire gil; \
21802180
pybind11::function override = pybind11::get_override(static_cast<const cname *>(this), name); \
21812181
if (override) { \
2182-
auto o = override(__VA_ARGS__); \
2182+
auto o = override.operator()<pybind11::return_value_policy::reference>(__VA_ARGS__); \
21832183
if (pybind11::detail::cast_is_temporary_value_reference<ret_type>::value) { \
21842184
static pybind11::detail::override_caster_t<ret_type> caster; \
21852185
return pybind11::detail::cast_ref<ret_type>(std::move(o), caster); \

0 commit comments

Comments
 (0)