Skip to content

Commit ee8aca7

Browse files
rwgklanctot
authored andcommitted
Replace PYBIND11_OVERRIDE_IMPL with PYBIND11_OVERRIDE_NAME
`PYBIND11_OVERRIDE_IMPL` is an implementation detail and not meant to be used outside the pybind11 source tree. Notes: * For easy reference: `PYBIND11_OVERRIDE_IMPL` was added to python_games.cc in cl/379240506. * Discovered in connection with google/pybind11clif#30015, which changes `PYBIND11_OVERRIDE_IMPL`. (The pywrapcc fork of pybind11 is not currently used in production, but we're using it regularly to run TAP Global Presubmits, to test go/pyclif_pybind11_fusion developments.) * FYI: Test coverage seems to be incomplete: control flow passes through the changed code for many tests, but replacing `"mean_field_population"` with `"XXXmean_field_population"` does not break any tests (see isolated TGP results under http://tap/OCL:517999370:BASE:517998831:1679332509158:a5f7412a). I.e. a test with a Python override is missing. * FYI: The `PYBIND11_OVERLOAD_*` macros used in other parts of python_games.cc are deprecated since Sep 2020 (pybind/pybind11#2325). It is recommended to replace them with the equivalent `PYBIND11_OVERRIDE_*` macros. PiperOrigin-RevId: 518266312 Change-Id: Ica90764a71b8ed7795b2f26ab02a904bf2ad901e
1 parent f7a4340 commit ee8aca7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

open_spiel/python/pybind11/python_games.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,10 @@ std::string PyState::Serialize() const {
369369
}
370370

371371
int PyState::MeanFieldPopulation() const {
372-
// Use a python population() implementation if available.
373-
PYBIND11_OVERRIDE_IMPL(int, State, "mean_field_population");
374-
375-
// Otherwise, default to behavior from the base class.
376-
return State::MeanFieldPopulation();
372+
// Use a Python implementation if available, fall back to the C++
373+
// implementation if not.
374+
PYBIND11_OVERRIDE_NAME(int, State, "mean_field_population",
375+
MeanFieldPopulation, /* no arguments */);
377376
}
378377

379378
} // namespace open_spiel

0 commit comments

Comments
 (0)