Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Propagating embedded Python Exceptions up to C++

If I have C++ code with embedded Python functions, i.e. it uses Python's C API to call Python's interpreter, how can I get Python exceptions to bubble up to the C++ level?


Note: This is not the inverse question (about propagating C++ extension exceptions up to the Python intepreter).

like image 301
Will Avatar asked Nov 11 '22 06:11

Will


1 Answers

https://docs.python.org/2/c-api/exceptions.html

specifically, PyErr_PrintEx(0) -- this will print a traceback.

like image 178
amwinter Avatar answered Nov 15 '22 05:11

amwinter