[glom] Python embedding: Deal with TODO.



commit 8640e266a8cc9e2e962ee752ce97da901ea105a8
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Apr 3 02:22:28 2013 +0200

    Python embedding: Deal with TODO.
    
        * glom/libglom/python_embed/pygdavalue_conversions.cc:
        Avoid a redefinition of PyDateTime_IMPORT for python 2.7
        and later, which fixes the compiler error.

 ChangeLog                                          |    8 ++++++++
 .../libglom/python_embed/pygdavalue_conversions.cc |   12 +++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b6a7679..700b1da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2013-04-03  Murray Cumming  <murrayc murrayc com>
 
+       Python embedding: Deal with TODO.
+
+       * glom/libglom/python_embed/pygdavalue_conversions.cc:
+       Avoid a redefinition of PyDateTime_IMPORT for python 2.7
+       and later, which fixes the compiler error.
+
+2013-04-03  Murray Cumming  <murrayc murrayc com>
+
        Deal with a minor TODO.
 
        * glom/frame_glom.h: Make the signal handlers private.
diff --git a/glom/libglom/python_embed/pygdavalue_conversions.cc 
b/glom/libglom/python_embed/pygdavalue_conversions.cc
index 42b95d1..11f279d 100644
--- a/glom/libglom/python_embed/pygdavalue_conversions.cc
+++ b/glom/libglom/python_embed/pygdavalue_conversions.cc
@@ -100,14 +100,20 @@ glom_pygda_value_from_pyobject(GValue* boxed, const boost::python::object& input
     }
     
 #if PY_VERSION_HEX >= 0x02040000
-    //TODO: Remove this redefine when Python fixes the compiler error in their macro:
-    // http://bugs.python.org/issue7463
+
     // Note that this sets a local copy of PyDateTimeAPI (in Python's datetime.h
     // header) so it _must_ be repeated and called before any code that use the
     // Python PyDate* macros (!) such as PyDateTime_Check
 
-    // PyDateTime_IMPORT; //A macro, needed to use PyDate_Check(), PyDateTime_Check(), etc.
+    //Python versions before python 2.7 have a compiler error in their PyDateTime_IMPORT macro:
+    // http://bugs.python.org/issue7463
+    // so we reimplement the macro for older versions:
+#if PY_VERSION_HEX >= 0x02070000
+    PyDateTime_IMPORT; //A macro, needed to use PyDate_Check(), PyDateTime_Check(), etc.
+#else
     PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import((char*)"datetime", (char*)"datetime_CAPI");
+#endif
+
     if(PyDateTimeAPI) //This should have been set but it can fail: 
https://bugzilla.gnome.org/show_bug.cgi?id=644702
     {
       //TODO: Find some way to do this with boost::python


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]