Skip to content

Commit 1f43d9e

Browse files
committed
Restore backtrace when raising Python exceptions
i.e. Python => C++ => Python
1 parent c344b90 commit 1f43d9e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ find_package(ElementsProject)
66
#---------------------------------------------------------------
77

88
# Declare project name and version
9-
elements_project(SourceXtractorPlusPlus 0.19 USE Alexandria 2.27 DESCRIPTION "SourceXtractor++, the next generation SExtractor")
9+
elements_project(SourceXtractorPlusPlus 0.19 USE Alexandria 2.28 DESCRIPTION "SourceXtractor++, the next generation SExtractor")

SEPythonModule/src/lib/SePyMain.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ struct std_duration_from_timedelta {
104104
}
105105
};
106106

107+
void translate_pyston_exc(const Pyston::Exception& exc) {
108+
exc.restore();
109+
}
110+
107111
} // namespace
108112

109113
BOOST_PYTHON_MODULE(_SEPythonModule) {
@@ -206,6 +210,9 @@ BOOST_PYTHON_MODULE(_SEPythonModule) {
206210
// For custom segmentation
207211
py::def("AllFramesDone", &AllFramesDone::create);
208212

213+
// Pyston::Exception wrap Python errors, so unwrap them at the Python boundary
214+
py::register_exception_translator<Pyston::Exception>(&translate_pyston_exc);
215+
209216
// Import pyston into the interpreter so it is importable without tweaking PYTHONPATH
210217
#if PY_MAJOR_VERSION >= 3
211218
PyObject* pyston = PyInit_pyston();

0 commit comments

Comments
 (0)