Last active
June 1, 2020 13:54
-
-
Save kohnakagawa/a5fc1e974e118615031730c7ab8d5b71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <pybind11/pybind11.h> | |
| #include <stdexcept> | |
| void func() { | |
| // NOTE: If Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS are not commented out, calling "func" exits with SIGSEGV. | |
| // Py_BEGIN_ALLOW_THREADS | |
| throw std::logic_error("an exception occurred"); | |
| // Py_END_ALLOW_THREADS | |
| } | |
| PYBIND11_MODULE(example, m) { | |
| m.doc() = "Example pybind11"; // optional module docstring | |
| m.def("func", func, "throw exception"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.