Skip to content

Commit 1314695

Browse files
committed
correctly pass foo2 by reference
1 parent e613f8d commit 1314695

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

eval-set-object/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int main()
2323

2424
auto module = py::module::import("foo_module");
2525

26-
auto locals = py::dict("foo_copy"_a=foo1, "foo_ref"_a=&foo2, **module.attr("__dict__")); // note the &
26+
auto locals = py::dict("foo_copy"_a=foo1, "foo_ref"_a=py::cast(foo2, py::return_value_policy::reference), **module.attr("__dict__")); // foo1 by value, foo2 by reference
2727
py::exec(R"(
2828
print(foo_copy.bar);
2929
foo_copy.bar = 5;

0 commit comments

Comments
 (0)