Broken usage of pybind11 "keep_alive" annotation

Aperta
#5,140 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Mizux ci sta già lavorando.

Dal 13/5/2026.

  • #5145 di @KasimVali2207 — chiusa senza merge

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Dependencies Lang: Python Solver: CP-SAT Solver

What version of OR-Tools and what language are you using?
Version: main/v9.15
Language: Python

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
n/a

What operating system (Linux, Windows, ...) and version?

What did you do?
Compile it

What did you expect to see
no errors

What did you see instead?

[  762s]  2870 |     .def_property_readonly(
[  762s]       |     ~~~~~~~~~~~~~~~~~~~~~~^
[  762s]  2871 |         "tails",
[  762s]       |         ~~~~~~~~           
[  762s]  2872 |         [](operations_research::sat::CircuitConstraintProto* self) { return self->mutable_tails(); },
[  762s]       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[  762s]  2873 |         py::return_value_policy::reference, py::keep_alive<0, 1>())
[  762s]       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[  762s] /usr/include/pybind11/pybind11.h:2659:25: error: static assertion failed: def_property family does not currently support keep_alive. Use a py::cpp_function instead.

While this error message is specific to current pybind11 versions, the actual error is inside the or-tools code, and the generated code is also wrong with the bundled pybind11.

For details, see https://github.com/pybind/pybind11/pull/5533

Lingua principale
C++
Stelle
14.5k
Fork
2.6k
Merge medio
9h 43m
PR unite (30g)
53

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google/or-tools

Tutte le issue di google/or-tools

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.