Skip to content

Conversation

@wangxf123456
Copy link
Contributor

@wangxf123456 wangxf123456 commented Apr 4, 2023

Description

Merge pybind/pybind11#4597 (Allow specializations based on callback function return values and arguments) with pywrapcc.

Additionally make func_wrapper use return_value_policy_pack.

@google-cla
Copy link

google-cla bot commented Apr 4, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@wangxf123456 wangxf123456 force-pushed the merge-status-callback branch from 2e6a545 to 76f7a7b Compare April 4, 2023 22:03
struct func_wrapper_base {
func_handle hfunc;
return_value_policy_pack rvpp;
explicit func_wrapper_base(func_handle &&hf, const return_value_policy_pack &rvpp) noexcept
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explicit is not longer accurate/needed.

@wangxf123456 wangxf123456 marked this pull request as ready for review April 4, 2023 22:35
@wangxf123456 wangxf123456 merged commit d1b83fd into google:main Apr 4, 2023
@wangxf123456 wangxf123456 deleted the merge-status-callback branch April 4, 2023 23:15
copybara-service bot pushed a commit to pybind/pybind11_abseil that referenced this pull request Jan 9, 2024
…ns to capture C++ exceptions.

This change builds on google/pybind11clif#30022.

PiperOrigin-RevId: 597047935
rwgk added a commit to google/clif that referenced this pull request Jan 22, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants