Move Python.h includes out of the headers into the .cpp file where it's actually used.

Python.h includes a ton of macros that can cause weird behavior down the road.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@142754 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Core/FormatClasses.cpp b/source/Core/FormatClasses.cpp
index abfb7fd..ef06734 100644
--- a/source/Core/FormatClasses.cpp
+++ b/source/Core/FormatClasses.cpp
@@ -8,6 +8,11 @@
 //===----------------------------------------------------------------------===//
 
 // C Includes
+#if defined (__APPLE__)
+#include <Python/Python.h>
+#else
+#include <Python.h>
+#endif
 
 // C++ Includes
 #include <ostream>
@@ -243,7 +248,12 @@
     if (m_interpreter == NULL)
         m_wrapper = NULL;
     else
-        m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend);
+        m_wrapper = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend);
+}
+
+SyntheticScriptProvider::FrontEnd::~FrontEnd()
+{
+  Py_XDECREF((PyObject*)m_wrapper);
 }
 
 lldb::ValueObjectSP
diff --git a/source/Interpreter/ScriptInterpreterPython.cpp b/source/Interpreter/ScriptInterpreterPython.cpp
index 6b71c82..70fb3f8 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Interpreter/ScriptInterpreterPython.cpp
@@ -8,8 +8,13 @@
 //===----------------------------------------------------------------------===//
 
 // In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included in ScriptInterpreterPython.h, and that
-// must be the *FIRST* header file included here.
+// the *FIRST* header file included here.
+
+#if defined (__APPLE__)
+#include <Python/Python.h>
+#else
+#include <Python.h>
+#endif
 
 #include "lldb/Interpreter/ScriptInterpreterPython.h"
 
@@ -242,11 +247,11 @@
         {
             while (!GetPythonLock (1))
                 fprintf (tmp_fh, "Python interpreter locked on another thread; waiting to acquire lock...\n");
-            Py_DECREF (m_new_sysout);
+            Py_DECREF ((PyObject*)m_new_sysout);
             ReleasePythonLock ();
         }
         else
-            Py_DECREF (m_new_sysout);
+            Py_DECREF ((PyObject*)m_new_sysout);
     }
 }
 
@@ -358,7 +363,7 @@
     if ((m_new_sysout != NULL)
         && (sysmod != NULL)
         && (sysdict != NULL))
-            PyDict_SetItemString (sysdict, "stdout", m_new_sysout);
+            PyDict_SetItemString (sysdict, "stdout", (PyObject*)m_new_sysout);
             
     if (PyErr_Occurred())
         PyErr_Clear ();