python - 将嵌入式 Python 异常传播到 C++

标签 python c++ exception-handling embedding

如果我有带有嵌入式 Python 函数的 C++ 代码,它使用 Python 的 C API 来调用 Python 的解释器,我怎样才能让 Python 异常冒泡到 C++ 级别?


注意:不是逆向问题(关于将 C++ 扩展异常传播到 Python 解释器)。

最佳答案

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

具体来说,PyErr_PrintEx(0) —— 这将打印回溯。

关于python - 将嵌入式 Python 异常传播到 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24090480/

相关文章:

python - Python 3 和 SQLite3 的 `table "django_migrations "already exists` 错误

Python线程: How to build a dictionary from the results

python - 如何在 AWS Elastic Beanstalk 上强制应用程序版本

c++ - 错误 : undefined reference to `sqlite3_open'

java - 不抛出测试异常

exception-handling - Ninject - 如何在构造过程中识别哪个类抛出异常

Python:在字典中创建字典以转换为 JSON

c++ - C++中带有空尖括号的模板<>是什么意思?

c++ - 查找 QTreeWidgetItem 是否为顶级

spring - 如何在IntelliJ IDEA中应用@ControllerAdvice?