Skip to content

Commit 12e3ca2

Browse files
tab/space conundrum
1 parent 9b32326 commit 12e3ca2

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

devs/adevs_python.hpp

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ class Atomic: public AtomicBase {
8888
bool isDefined = this->pythonObject_ && this->deltaIntFunc_;
8989
if (isDefined){
9090
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+
}
9797
else
9898
throw std::bad_function_call();
9999

@@ -106,12 +106,12 @@ class Atomic: public AtomicBase {
106106
bool isDefined = this->pythonObject_ && this->deltaExtFunc_;
107107
if (isDefined){
108108
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+
}
115115
else
116116
throw std::bad_function_call();
117117

@@ -124,12 +124,12 @@ class Atomic: public AtomicBase {
124124
bool isDefined = this->pythonObject_ && this->deltaConfFunc_;
125125
if (isDefined){
126126
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+
}
133133
else
134134
throw std::bad_function_call();
135135
}
@@ -140,18 +140,18 @@ class Atomic: public AtomicBase {
140140

141141
bool isDefined = this->pythonObject_ && this->outputFunc_;
142142
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+
}
151151
else
152-
{
152+
{
153153
throw std::bad_function_call();
154-
}
154+
}
155155

156156
}
157157

@@ -191,26 +191,26 @@ class Atomic: public AtomicBase {
191191
}
192192

193193

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+
}
214214

215215
private:
216216

0 commit comments

Comments
 (0)