-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: properly translate C++ exception to Python exception when creating Python buffer from wrapped object #5324
Conversation
This required a little refactoring to extract exception translation to a separate method
I need to find a block of time to look carefully. But high-level: There is already too much stuff in internals.h, adding in the exception translator code seems very unfortunate. pybind11 is poorly factored in general, I'd love to not make it worse, even though it can get tricky sometimes. Could you please try to move the exception translator code into its own header, maybe pybind11/detail/exception_translators.h? You'll have to update a couple files when adding a new header. An easy way to pin-point the locations is e.g.:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple minor suggestions. I only glanced through. Looks great, although I still want to look more carefully later (maybe weekend).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
The suggestions are really minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henryiii @EthanSteinberg @Skylion007: Do you have ~10 minutes for a second review?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, nice job!
(As a side note though, def_buffer seems to have a way more convoluted design than it should ...)
Thanks a lot @EthanSteinberg for the review! |
…thon 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>
…thon 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>
Description
Fatal Python error
without the fix (unhandlable from within Python) and passes after it is done.Closes: #2764, #3336
Suggested changelog entry: