Skip to content
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

[BUG]: Can't catch the exception in Python that raise in C++ using py::error_already_set() #5290

Open
3 tasks done
QunBB opened this issue Aug 6, 2024 · 0 comments
Open
3 tasks done
Labels
triage New bug, unverified

Comments

@QunBB
Copy link

QunBB commented Aug 6, 2024

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.10.0

Problem description

When i use the below reproducible example code, I can't catch the exception IndexError in Python that raise in C++.
The log is:

before exception

Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)

Reproducible example code

m.def("test_exception", []() { 
        std::cout << "before exception" << std::endl;

        PyErr_SetString(PyExc_IndexError, "Here is an IndexError");
        throw py::error_already_set();
        
        std::cout << "after exception" << std::endl;
        });
test_exception()

Is this a regression? Put the last known working version here if it is.

Not a regression

@QunBB QunBB added the triage New bug, unverified label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New bug, unverified
Projects
None yet
Development

No branches or pull requests

1 participant