-
Notifications
You must be signed in to change notification settings - Fork 212
Handling errors inside BOOST_PYTHON_MODULE() #280
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
Comments
What happens if you replace |
No, switching to Lines 48 to 51 in ac62db1
and verified that this catch case was executed. |
OK, I see. So the Python error has correctly been set by Boost.Python, but Python's own runtime then flags this as an "unreported exception". In other words, you could strip your code off all Boost.Python references, only using Python's own C API, and you'd still observe the issue. |
Are you sure that's a Python problem? Maybe Line 24 in 1727b67
should be replaced with if (handle_exception(init_function)) return NULL; ? |
Oh, indeed, that looks sensible. Can you write a (minimal) test case to demonstrate the problem as well as that your proposed change fixes it ? That would make a great PR ! |
I just tried to fix it locally this way and it solved the problem. Well, I could try to create a test case and PR, but I'm quite new to boost libs testing infrastructure... |
OK, great. I'll see whether I can write a quick test. |
Hi @stefanseefeld |
Had the same issue, boost::python was hiding the real exception with |
Also just ran into this problem.. Just bumping this issue to show it's still relevant and affects users. |
I finally decided to stop waiting for something and create PR myself |
I have a module that may fail to initialize due to missing dependencies. So I do
The exception is correctly caught and
PyErr_SetString(PyExc_RuntimeError, x.what())
is called, but python reportsWhy
unreported exception
? My platform is Windows 10/Python 3.7.4 x64/MSVC 2017 if that matters. python_boost version is 1.69.0.The text was updated successfully, but these errors were encountered: