@@ -199,45 +199,24 @@ class Atomic: public AtomicBase {
199
199
PyObject *ptype, *pvalue, *ptraceback;
200
200
PyObject *pystr, *pystr_unic;
201
201
202
+ std::string error_desc;
202
203
PyErr_Fetch (&ptype, &pvalue, &ptraceback);
203
- pystr = PyObject_Str (pvalue);
204
- pystr_unic = PyUnicode_AsEncodedString (pystr, " utf-8" , " ~E~" );
205
- std::string error_desc {PyBytes_AsString (pystr_unic)};
206
- Py_XDECREF (pystr);
207
- Py_XDECREF (pystr_unic);
208
-
209
- // try to get traceback as per https://stackoverflow.com/a/15907460
210
-
211
- /* See if we can get a full traceback */
212
- std::string full_backtrace = " " ;
213
- PyObject *pyth_module, *pyth_func;
214
- pyth_module = PyImport_ImportModule (" traceback" );
215
- if (pyth_module == NULL ) {
216
- full_backtrace = " " ;
204
+ if (pvalue == NULL ){
205
+ error_desc = {" No information on the occured exception available" };
217
206
}
218
207
else {
208
+ pystr = PyObject_Str (pvalue);
209
+ pystr_unic = PyUnicode_AsEncodedString (pystr, " utf-8" , " ignore" );
210
+ error_desc = {PyBytes_AsString (pystr_unic)};
219
211
220
- pyth_func = PyObject_GetAttrString (pyth_module, " format_exception" );
221
- if (pyth_func && PyCallable_Check (pyth_func)) {
222
- PyObject *pyth_val;
223
-
224
- pyth_val = PyObject_CallFunctionObjArgs (pyth_func, ptype, pvalue, ptraceback, NULL );
225
-
226
- pystr = PyObject_Str (pyth_val);
227
- pystr_unic = PyUnicode_AsEncodedString (pystr, " utf-8" , " ~E~" );
228
- full_backtrace = {PyBytes_AsString (pystr_unic)};
229
-
230
- Py_XDECREF (pyth_val);
231
- Py_XDECREF (pyth_func);
232
- Py_XDECREF (pystr);
212
+ Py_XDECREF (pystr);
233
213
Py_XDECREF (pystr_unic);
214
+ }
234
215
Py_XDECREF (ptype);
235
216
Py_XDECREF (pvalue);
236
217
Py_XDECREF (ptraceback);
237
218
238
- }
239
- }
240
- return error_desc + full_backtrace;
219
+ return " Python traceback follows:\n " + error_desc;
241
220
}
242
221
243
222
private:
0 commit comments