Skip to content

Commit bdcf172

Browse files
committed
sat: fix python cp_model_helper build
1 parent 7419651 commit bdcf172

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ortools/sat/python/cp_model_helper.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,7 @@ PYBIND11_MODULE(cp_model_helper, m) {
18711871
.def(py::init<std::shared_ptr<CpModelProto>, int>())
18721872
.def(py::init<std::shared_ptr<CpModelProto>>()) // new variable.
18731873
.def_property_readonly(
1874-
"proto", &IntVar::proto, py::return_value_policy::reference,
1875-
py::keep_alive<1, 0>(),
1874+
"proto", &IntVar::proto, py::return_value_policy::reference_internal,
18761875
"Returns the IntegerVariableProto of this variable.")
18771876
.def_property_readonly("model_proto", &IntVar::model_proto,
18781877
"Returns the CP model protobuf")
@@ -2120,8 +2119,7 @@ PYBIND11_MODULE(cp_model_helper, m) {
21202119
.def_property_readonly("model_proto", &Constraint::model_proto,
21212120
"Returns the model protobuf.")
21222121
.def_property_readonly("proto", &Constraint::proto,
2123-
py::return_value_policy::reference,
2124-
py::keep_alive<1, 0>(),
2122+
py::return_value_policy::reference_internal,
21252123
"Returns the ConstraintProto of this constraint.")
21262124
.def_property("name", &Constraint::name, &Constraint::SetName,
21272125
"The name of the constraint.")
@@ -2236,9 +2234,9 @@ intervals into the schedule.
22362234
"Returns the index of the interval variable.")
22372235
.def_property_readonly("model_proto", &IntervalVar::model_proto,
22382236
"Returns the model protobuf.")
2239-
.def_property_readonly(
2240-
"proto", &IntervalVar::proto, py::return_value_policy::reference,
2241-
py::keep_alive<1, 0>(), "Returns the interval constraint protobuf.")
2237+
.def_property_readonly("proto", &IntervalVar::proto,
2238+
py::return_value_policy::reference_internal,
2239+
"Returns the interval constraint protobuf.")
22422240
.def_property("name", &IntervalVar::name, &IntervalVar::SetName,
22432241
"The name of the interval variable.")
22442242
.def(

0 commit comments

Comments
 (0)