Commit 649bf869 authored by John Tourtellott's avatar John Tourtellott
Browse files

Add return value to vtkPythonInterpreter::RunSimpleString()

The python call returns 0 for success or -1 for exception.
Pass that return value to the caller.
parent 88f5b3ee
......@@ -229,7 +229,7 @@ int vtkPythonInterpreter::PyMain(int argc, char** argv)
}
//----------------------------------------------------------------------------
void vtkPythonInterpreter::RunSimpleString(const char* script)
int vtkPythonInterpreter::RunSimpleString(const char* script)
{
vtkPythonInterpreter::Initialize(1);
vtkPythonInterpreter::ConsoleBuffering = true;
......@@ -240,7 +240,7 @@ void vtkPythonInterpreter::RunSimpleString(const char* script)
buffer.erase(std::remove(buffer.begin(), buffer.end(), '\r'), buffer.end());
// The cast is necessary because PyRun_SimpleString() hasn't always been const-correct
PyRun_SimpleString(const_cast<char*>(buffer.c_str()));
int pyReturn = PyRun_SimpleString(const_cast<char*>(buffer.c_str()));
vtkPythonInterpreter::ConsoleBuffering = false;
if (! vtkPythonInterpreter::StdErrBuffer.empty())
{
......@@ -254,6 +254,8 @@ void vtkPythonInterpreter::RunSimpleString(const char* script)
vtkPythonInterpreter::StdOutBuffer.c_str()));
vtkPythonInterpreter::StdOutBuffer.clear();
}
return pyReturn;
}
//----------------------------------------------------------------------------
......
......@@ -94,7 +94,8 @@ public:
// is provided to overcome an issue with the Python interpreter with handling
// of DOS line endings.
// This will initialize Python if not already initialized.
static void RunSimpleString(const char* script);
// Returns 0 on success or -1 if a python exception was raised.
static int RunSimpleString(const char* script);
// Description:
// Prepends the path to the sys.path variable. If Python has been
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment