--- /dev/null
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/CMakeLists.txt ParaView-4.1.0_SRC-new/CMakeLists.txt
+--- ParaView-4.1.0_SRC-orig/CMakeLists.txt 2014-01-11 17:59:57.000000000 +0400
++++ ParaView-4.1.0_SRC-new/CMakeLists.txt 2014-05-05 12:30:42.000000000 +0400
+@@ -511,7 +511,7 @@
+
+ #----------------------------------------------------------------------------------
+ # Set some flags that affect VTK's modules.
+- set (VTK_NO_PYTHON_THREADS 1 CACHE INTERNAL
++ set (VTK_NO_PYTHON_THREADS OFF CACHE INTERNAL
+ "Disable Python Threads support" FORCE)
+ set(VTK_WRAP_PYTHON ${PARAVIEW_ENABLE_PYTHON}
+ CACHE INTERNAL "Should VTK Python wrapping be built?" FORCE)
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx ParaView-4.1.0_SRC-new/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx
+--- ParaView-4.1.0_SRC-orig/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx 2014-01-11 17:59:57.000000000 +0400
++++ ParaView-4.1.0_SRC-new/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx 2014-05-05 12:30:57.000000000 +0400
+@@ -276,7 +276,7 @@
+ {
+ if (!info)
+ {
+- vtkWarningMacro("Could not determine array range.");
++ // vtkWarningMacro("Could not determine array range.");
+ return false;
+ }
+
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h ParaView-4.1.0_SRC-new/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h
+--- ParaView-4.1.0_SRC-orig/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h 2014-01-11 17:59:57.000000000 +0400
++++ ParaView-4.1.0_SRC-new/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h 2014-05-05 12:30:42.000000000 +0400
+@@ -19,27 +19,15 @@
+
+ #include "vtkPVVTKExtensionsDefaultModule.h" //needed for exports
+
+-#ifdef PARAVIEW_USE_MPI
+-#include "vtkMPIImageReader.h"
+-#else
+ #include "vtkImageReader.h"
+-#endif
+
+-class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkPVImageReader : public
+-#ifdef PARAVIEW_USE_MPI
+-vtkMPIImageReader
+-#else
+-vtkImageReader
+-#endif
++class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkPVImageReader : public vtkImageReader
+ {
+ public:
+ static vtkPVImageReader* New();
+
+-#ifdef PARAVIEW_USE_MPI
+- vtkTypeMacro(vtkPVImageReader, vtkMPIImageReader);
+-#else
++
+ vtkTypeMacro(vtkPVImageReader, vtkImageReader);
+-#endif
+
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/Qt/Python/pqPythonManager.cxx ParaView-4.1.0_SRC-new/Qt/Python/pqPythonManager.cxx
+--- ParaView-4.1.0_SRC-orig/Qt/Python/pqPythonManager.cxx 2014-01-11 18:00:00.000000000 +0400
++++ ParaView-4.1.0_SRC-new/Qt/Python/pqPythonManager.cxx 2014-05-05 12:30:42.000000000 +0400
+@@ -139,7 +139,7 @@
+ // initialized (by a startup plugin, for example)
+ if (vtkPythonInterpreter::IsInitialized())
+ {
+- importParaViewModule();
++ //importParaViewModule();
+ }
+ }
+ ~pqInternal()
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Common/Core/vtkCharArray.h ParaView-4.1.0_SRC-new/VTK/Common/Core/vtkCharArray.h
+--- ParaView-4.1.0_SRC-orig/VTK/Common/Core/vtkCharArray.h 2014-01-11 18:02:05.000000000 +0400
++++ ParaView-4.1.0_SRC-new/VTK/Common/Core/vtkCharArray.h 2014-05-05 12:30:42.000000000 +0400
+@@ -48,7 +48,26 @@
+ // make up the interface of vtkDataArrayTemplate, which is ignored
+ // by the wrappers.
+ #ifdef __WRAP__
+- vtkCreateWrappedArrayInterface(char);
++// vtkCreateWrappedArrayInterface(char);
++
++ // [ABN] manual macro expansion to avoid the last 4 methods (they were BTX/ETX enclosed in
++ // prev versions of PV, meaning not included in the wrapping).
++ int GetDataType();
++ void GetTupleValue(vtkIdType i, char* tuple);
++ void SetTupleValue(vtkIdType i, const char* tuple);
++ void InsertTupleValue(vtkIdType i, const char* tuple);
++ vtkIdType InsertNextTupleValue(const char* tuple);
++ char GetValue(vtkIdType id);
++ void SetValue(vtkIdType id, char value);
++ void SetNumberOfValues(vtkIdType number);
++ void InsertValue(vtkIdType id, char f);
++ vtkIdType InsertNextValue(char f);
++
++// T *GetValueRange(int comp);
++// T *GetValueRange();
++// T* WritePointer(vtkIdType id, vtkIdType number);
++// T* GetPointer(vtkIdType id);
++
+ #endif
+
+ // Description:
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx ParaView-4.1.0_SRC-new/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx
+--- ParaView-4.1.0_SRC-orig/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx 2014-01-11 18:02:10.000000000 +0400
++++ ParaView-4.1.0_SRC-new/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx 2014-05-05 12:30:42.000000000 +0400
+@@ -74,7 +74,7 @@
+ //----------------------------------------------------------------------------
+ vtkMatplotlibMathTextUtilities::Availablity
+ vtkMatplotlibMathTextUtilities::MPLMathTextAvailable =
+-vtkMatplotlibMathTextUtilities::NOT_TESTED;
++vtkMatplotlibMathTextUtilities::UNAVAILABLE;
+
+ // A macro that is used in New() to print warnings if VTK_MATPLOTLIB_DEBUG
+ // is defined in the environment. Use vtkGenericWarningMacro to allow this to
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Utilities/Python/vtkPython.h ParaView-4.1.0_SRC-new/VTK/Utilities/Python/vtkPython.h
+--- ParaView-4.1.0_SRC-orig/VTK/Utilities/Python/vtkPython.h 2014-01-11 18:02:13.000000000 +0400
++++ ParaView-4.1.0_SRC-new/VTK/Utilities/Python/vtkPython.h 2014-05-05 12:30:42.000000000 +0400
+@@ -87,4 +87,14 @@
+ #error "Python.h is different version from what VTK was configured with!!"
+ #endif
+
++#ifdef VTK_NO_PYTHON_THREADS
++# define VTK_PY_GIL_ENSURE
++# define VTK_PY_GIL_RELEASE
++#else
++# define VTK_PY_GIL_ENSURE PyGILState_STATE _gstate_avoid_clash = PyGILState_Ensure();
++# define VTK_PY_GIL_RELEASE PyGILState_Release(_gstate_avoid_clash);
++#
++#endif
++
++
+ #endif
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx
+--- ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx 2014-01-11 18:02:13.000000000 +0400
++++ ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx 2014-05-05 12:30:42.000000000 +0400
+@@ -45,6 +45,7 @@
+
+ void CleanupPythonObjects()
+ {
++ VTK_PY_GIL_ENSURE
+ Py_XDECREF(this->InteractiveConsoleLocals);
+ Py_XDECREF(this->InteractiveConsole);
+ this->InteractiveConsole = NULL;
+@@ -54,6 +55,7 @@
+ const char* code = "import gc; gc.collect()\n";
+ vtkPythonInterpreter::RunSimpleString(code);
+ }
++ VTK_PY_GIL_RELEASE
+ }
+
+ PyObject* GetInteractiveConsole()
+@@ -65,6 +67,7 @@
+
+ vtkPythonInterpreter::Initialize();
+
++ VTK_PY_GIL_ENSURE
+ // set up the code.InteractiveConsole instance that we'll use.
+ const char* code = "import code\n"
+ "__vtkConsoleLocals={'__name__':'__vtkconsole__','__doc__':None}\n"
+@@ -83,6 +86,7 @@
+ {
+ vtkGenericWarningMacro(
+ "Failed to locate the InteractiveConsole/InteractiveConsoleLocals object.");
++ VTK_PY_GIL_RELEASE
+ return NULL;
+ }
+ Py_INCREF(this->InteractiveConsole);
+@@ -105,7 +109,7 @@
+ PySys_SetObject(const_cast<char*>("ps2"), ps2 = PyString_FromString("... "));
+ Py_XDECREF(ps2);
+ }
+-
++ VTK_PY_GIL_RELEASE
+ return this->InteractiveConsole;
+ }
+ };
+@@ -167,6 +171,7 @@
+ i++;
+ }
+
++ VTK_PY_GIL_ENSURE
+ bool ret_value = false;
+ PyObject *res = PyObject_CallMethod(console,
+ const_cast<char*>("push"), const_cast<char*>("z"), buffer.c_str());
+@@ -179,6 +184,7 @@
+ }
+ Py_DECREF(res);
+ }
++ VTK_PY_GIL_RELEASE
+ return ret_value;
+ }
+
+@@ -190,12 +196,14 @@
+
+ this->Internals->GetInteractiveConsole(); //ensure the console is initialized
+
++ VTK_PY_GIL_ENSURE
+ PyObject* context = this->Internals->GetInteractiveConsoleLocalsPyObject();
+ PyObject* result = PyRun_String(const_cast<char*>(script), Py_file_input, context, context);
+
+ if (result == NULL)
+ {
+ PyErr_Print();
++ VTK_PY_GIL_RELEASE
+ return -1;
+ }
+
+@@ -204,6 +212,7 @@
+ {
+ PyErr_Clear();
+ }
++ VTK_PY_GIL_RELEASE
+ return 0;
+ }
+
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx
+--- ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx 2014-01-11 18:02:13.000000000 +0400
++++ ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx 2014-05-05 12:30:42.000000000 +0400
+@@ -60,10 +60,12 @@
+
+ inline void vtkPrependPythonPath(const char* pathtoadd)
+ {
++ VTK_PY_GIL_ENSURE
+ PyObject* path = PySys_GetObject(const_cast<char*>("path"));
+ PyObject* newpath = PyString_FromString(pathtoadd);
+ PyList_Insert(path, 0, newpath);
+ Py_DECREF(newpath);
++ VTK_PY_GIL_RELEASE
+ }
+ }
+
+@@ -107,7 +109,6 @@
+ //----------------------------------------------------------------------------
+ bool vtkPythonInterpreter::Initialize(int initsigs /*=0*/)
+ {
+- vtkPythonInterpreter::InitializedOnce = true;
+ if (Py_IsInitialized() == 0)
+ {
+ #if (VTK_PYTHON_MAJOR_VERSION > 2) ||\
+@@ -117,11 +118,24 @@
+ (void)initsigs;
+ Py_Initialize();
+ #endif
+-
+ #ifdef SIGINT
+ // Put default SIGINT handler back after Py_Initialize/Py_InitializeEx.
+ signal(SIGINT, SIG_DFL);
+ #endif
++ }
++
++ if (! vtkPythonInterpreter::InitializedOnce)
++ {
++#ifndef VTK_NO_PYTHON_THREADS
++ PyEval_InitThreads(); // safe to call this multiple time
++#endif
++ // At this point we have GIL, or we are mono-thread.
++ // Access to the static below is safe:
++ vtkPythonInterpreter::InitializedOnce = true;
++
++#ifndef VTK_NO_PYTHON_THREADS
++ PyEval_ReleaseLock(); // release GIL
++#endif
+ // HACK: Calling PyRun_SimpleString for the first time for some reason results in
+ // a "\n" message being generated which is causing the error dialog to
+ // popup. So we flush that message out of the system before setting up the
+@@ -134,15 +148,17 @@
+ vtkPythonStdStreamCaptureHelper* wrapperErr =
+ NewPythonStdStreamCaptureHelper(true);
+
+- // Redirect Python's stdout and stderr and stdin
+- PySys_SetObject(const_cast<char*>("stdout"),
++ // Redirect Python's stdout and stderr and stdin - GIL protected operation
++ VTK_PY_GIL_ENSURE
++ int ret1 = PySys_SetObject(const_cast<char*>("stdout"),
+ reinterpret_cast<PyObject*>(wrapperOut));
+- PySys_SetObject(const_cast<char*>("stderr"),
++ int ret2 = PySys_SetObject(const_cast<char*>("stderr"),
+ reinterpret_cast<PyObject*>(wrapperErr));
+- PySys_SetObject(const_cast<char*>("stdin"),
++ int ret3 = PySys_SetObject(const_cast<char*>("stdin"),
+ reinterpret_cast<PyObject*>(wrapperOut));
+ Py_DECREF(wrapperOut);
+ Py_DECREF(wrapperErr);
++ VTK_PY_GIL_RELEASE
+
+ for (size_t cc=0; cc < PythonPaths.size(); cc++)
+ {
+@@ -213,6 +229,7 @@
+ }
+
+ //----------------------------------------------------------------------------
++// [ABN] not thread safe for now - only used by pvpython?
+ int vtkPythonInterpreter::PyMain(int argc, char** argv)
+ {
+ if (!vtkPythonInterpreter::InitializedOnce && Py_IsInitialized() == 0 &&
+@@ -235,7 +252,9 @@
+ buffer.erase(std::remove(buffer.begin(), buffer.end(), '\r'), buffer.end());
+
+ // The cast is necessary because PyRun_SimpleString() hasn't always been const-correct
++ VTK_PY_GIL_ENSURE
+ PyRun_SimpleString(const_cast<char*>(buffer.c_str()));
++ VTK_PY_GIL_RELEASE
+ }
+
+ //----------------------------------------------------------------------------
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx ParaView-4.1.0_SRC-new/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx
+--- ParaView-4.1.0_SRC-orig/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx 2014-01-11 18:02:14.000000000 +0400
++++ ParaView-4.1.0_SRC-new/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx 2014-05-05 12:30:42.000000000 +0400
+@@ -30,14 +30,18 @@
+ vtkPythonUtil::UnRegisterPythonCommand(this);
+ if (this->obj && Py_IsInitialized())
+ {
++ VTK_PY_GIL_ENSURE
+ Py_DECREF(this->obj);
++ VTK_PY_GIL_RELEASE
+ }
+ this->obj = NULL;
+ }
+
+ void vtkPythonCommand::SetObject(PyObject *o)
+ {
++ VTK_PY_GIL_ENSURE
+ Py_INCREF(o);
++ VTK_PY_GIL_RELEASE
+ this->obj = o;
+ }
+
+@@ -75,11 +79,11 @@
+ // If a threadstate has been set using vtkPythonCommand::SetThreadState,
+ // then swap it in here. See the email to vtk-developers@vtk.org from
+ // June 18, 2009 with subject "Py_NewInterpreter and vtkPythonCallback issue"
+- PyThreadState* prevThreadState = NULL;
+- if (this->ThreadState)
+- {
+- prevThreadState = PyThreadState_Swap(this->ThreadState);
+- }
++// PyThreadState* prevThreadState = NULL;
++// if (this->ThreadState)
++// {
++// prevThreadState = PyThreadState_Swap(this->ThreadState);
++// }
+
+ if (ptr && ptr->GetReferenceCount() > 0)
+ {
+@@ -176,10 +180,10 @@
+ }
+
+ // If we did the swap near the top of this function then swap back now.
+- if (this->ThreadState)
+- {
+- PyThreadState_Swap(prevThreadState);
+- }
++// if (this->ThreadState)
++// {
++// PyThreadState_Swap(prevThreadState);
++// }
+
+ #ifndef VTK_NO_PYTHON_THREADS
+ #if (PY_MAJOR_VERSION > 2) || \
+diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/Wrapping/Python/paraview/servermanager.py ParaView-4.1.0_SRC-new/Wrapping/Python/paraview/servermanager.py
+--- ParaView-4.1.0_SRC-orig/Wrapping/Python/paraview/servermanager.py 2014-01-11 18:00:00.000000000 +0400
++++ ParaView-4.1.0_SRC-new/Wrapping/Python/paraview/servermanager.py 2014-05-05 12:30:57.000000000 +0400
+@@ -1095,7 +1095,7 @@
+ property = self.SMProperty
+ nElems = property.GetNumberOfElements()
+ if nElems%2 != 0:
+- raise ValueError, "The SMProperty with XML label '%s' has a size that is not a multiple of 2." % property.GetXMLLabel()
++ nElems -= 1
+ self.__arrays = []
+ for i in range(0, nElems, 2):
+ if self.GetElement(i+1) != '0':