Skip to content

Conversation

@YannickJadoul
Copy link
Collaborator

@YannickJadoul YannickJadoul commented Dec 31, 2018

As discussed with @martinRenou and @bstaletic on Gitter, a with statement complying with the semantics of PEP 343 might be a useful utility to add to the pybind11 toolbox.

Since C++ will crash if an exception gets thrown while another one is already active, it seems impossible to have a safe RAII implementation of this. But for almost all purposes, this version, taking a function or lambda, should be sufficient.

This PR depends on @martinRenou's PR #1641 adding getters to py::error_already_set.

@wjakob
Copy link
Member

wjakob commented Jun 11, 2019

Hi Yannick,

this is certainly a neat idea and was clearly a lot of work. However, for me the C++ form of this feature is simply too awkward, and I find the implementation too complex to justify shipping a rather "niche" feature in header files that will be included downstream by all projects using pybind11. So I'll close this for now. If the implementation was substantially simpler, in a separate header file that is not used by default, and didn't require changes to central pybind11 logic, I might consider it.

Best,
Wenzel

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