Properly translate C++ exception to Python exception when creating Python buffer from wrapped object (#5324)

* Add test for throwing def_buffer case

* Translate C++ -> Python exceptions in buffer creation

This required a little refactoring to extract exception translation to a separate method

* Fix code formatting

* Fix "unused parameter" warning

* Refactor per review

* style: pre-commit fixes

* Address review comments

* Address review comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Vasily Litvinov
2024-09-02 19:01:59 +03:00
committed by GitHub
parent 66c3774a64
commit aeda49ed0b
7 changed files with 108 additions and 54 deletions

View File

@@ -135,6 +135,7 @@ set(PYBIND11_HEADERS
include/pybind11/detail/type_caster_base.h
include/pybind11/detail/typeid.h
include/pybind11/detail/value_and_holder.h
include/pybind11/detail/exception_translation.h
include/pybind11/attr.h
include/pybind11/buffer_info.h
include/pybind11/cast.h