Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change pybind11 handling of callbacks with
Status
, StatusOr
retur…
…ns to capture C++ exceptions. BEGIN_PUBLIC Change pybind11 handling of callbacks with `Status`, `StatusOr` returns to capture C++ exceptions. This change builds on google/pybind11clif#30022. END_PUBLIC The CL is mainly moving the `type_caster_std_function_specializations` code block from * google3/third_party/clif/pybind11/type_casters.h;l=42-74;rcl=532883006 into google3/third_party/pybind11_abseil/status_caster.h & google3/third_party/pybind11_abseil/statusor_caster.h. Additionally, the behavior for callbacks with a `Status` return is changed (`catch` `cast_error` in status_caster.h), to ensure that C++ exceptions do not unwind through C++ code built with exception handling disabled (see e.g. google3/third_party/pybind11_abseil/compat/README.md). Note that the added related test code (`testStatusWrongReturnType` in status_testing_no_cpp_eh_test_lib.py) exposed a behavior difference between PyCLIF-C-API and pybind11: returned objects are simply ignored by PyCLIF-C-API. Addressing this is left for later. All other changes are mainly to reorganize and expand the test code. (Note that the extensive, multi-year refactoring work around `Status`, `StatusOr`, `StatusNotOk` has left the related test code in a fairly unorganized state.) Notes for completeness: * This is a fairly fundamental behavior change, but somewhat surprisingly cl/596532587 was the only adjustment needed in google3. * TGP tested via child cl/578064081, which is only a very small additional production code change (fixing a very obvious bug), and will be submitted shortly after this CL. PiperOrigin-RevId: 597047935
- Loading branch information