@@ -88,12 +88,12 @@ class Atomic: public AtomicBase {
88
88
bool isDefined = this ->pythonObject_ && this ->deltaIntFunc_ ;
89
89
if (isDefined){
90
90
this ->deltaIntFunc_ (this ->pythonObject_ );
91
- if (PyErr_Occurred ())
92
- {
93
- std::string error_message = get_PyExceptionAsString ();
94
- throw std::runtime_error (error_message);
95
- }
96
- }
91
+ if (PyErr_Occurred ())
92
+ {
93
+ std::string error_message = get_PyExceptionAsString ();
94
+ throw std::runtime_error (error_message);
95
+ }
96
+ }
97
97
else
98
98
throw std::bad_function_call ();
99
99
@@ -106,12 +106,12 @@ class Atomic: public AtomicBase {
106
106
bool isDefined = this ->pythonObject_ && this ->deltaExtFunc_ ;
107
107
if (isDefined){
108
108
this ->deltaExtFunc_ (this ->pythonObject_ , e, xb);
109
- if (PyErr_Occurred ())
110
- {
111
- std::string error_message = get_PyExceptionAsString ();
112
- throw std::runtime_error (error_message);
113
- }
114
- }
109
+ if (PyErr_Occurred ())
110
+ {
111
+ std::string error_message = get_PyExceptionAsString ();
112
+ throw std::runtime_error (error_message);
113
+ }
114
+ }
115
115
else
116
116
throw std::bad_function_call ();
117
117
@@ -124,12 +124,12 @@ class Atomic: public AtomicBase {
124
124
bool isDefined = this ->pythonObject_ && this ->deltaConfFunc_ ;
125
125
if (isDefined){
126
126
this ->deltaConfFunc_ (this ->pythonObject_ , xb);
127
- if (PyErr_Occurred ())
128
- {
129
- std::string error_message = get_PyExceptionAsString ();
130
- throw std::runtime_error (error_message);
131
- }
132
- }
127
+ if (PyErr_Occurred ())
128
+ {
129
+ std::string error_message = get_PyExceptionAsString ();
130
+ throw std::runtime_error (error_message);
131
+ }
132
+ }
133
133
else
134
134
throw std::bad_function_call ();
135
135
}
@@ -140,18 +140,18 @@ class Atomic: public AtomicBase {
140
140
141
141
bool isDefined = this ->pythonObject_ && this ->outputFunc_ ;
142
142
if (isDefined)
143
- {
144
- this ->outputFunc_ (this ->pythonObject_ , yb);
145
- if (PyErr_Occurred ())
146
- {
147
- std::string error_message = get_PyExceptionAsString ();
148
- throw std::runtime_error (error_message);
149
- }
150
- }
143
+ {
144
+ this ->outputFunc_ (this ->pythonObject_ , yb);
145
+ if (PyErr_Occurred ())
146
+ {
147
+ std::string error_message = get_PyExceptionAsString ();
148
+ throw std::runtime_error (error_message);
149
+ }
150
+ }
151
151
else
152
- {
152
+ {
153
153
throw std::bad_function_call ();
154
- }
154
+ }
155
155
156
156
}
157
157
@@ -191,26 +191,26 @@ class Atomic: public AtomicBase {
191
191
}
192
192
193
193
194
- std::string get_PyExceptionAsString ()
195
- {
196
- // now we will try to get the python traceback.
197
- // see https://stackoverflow.com/questions/1796510/accessing-a-python-traceback-from-the-c-api
198
- // for longer discussion on how to do it.
199
- PyObject *ptype, *pvalue, *ptraceback;
200
- PyObject *pystr, *pystr_unic;
201
-
202
- 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 (ptype);
207
- Py_XDECREF (pvalue);
208
- Py_XDECREF (ptraceback);
209
- Py_XDECREF (pystr);
210
- Py_XDECREF (pystr_unic);
211
-
212
- return error_desc;
213
- }
194
+ std::string get_PyExceptionAsString ()
195
+ {
196
+ // now we will try to get the python traceback.
197
+ // see https://stackoverflow.com/questions/1796510/accessing-a-python-traceback-from-the-c-api
198
+ // for longer discussion on how to do it.
199
+ PyObject *ptype, *pvalue, *ptraceback;
200
+ PyObject *pystr, *pystr_unic;
201
+
202
+ 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 (ptype);
207
+ Py_XDECREF (pvalue);
208
+ Py_XDECREF (ptraceback);
209
+ Py_XDECREF (pystr);
210
+ Py_XDECREF (pystr_unic);
211
+
212
+ return error_desc;
213
+ }
214
214
215
215
private:
216
216
0 commit comments