]> sigrok.org Git - libsigrok.git/commitdiff
python: Fix the build for Python >= 3.
authorUwe Hermann <redacted>
Mon, 31 Aug 2015 19:08:08 +0000 (21:08 +0200)
committerUwe Hermann <redacted>
Mon, 31 Aug 2015 19:08:08 +0000 (21:08 +0200)
SWIG_init() returns void for Python 2.x and 'PyObject *' for Python 3.

Use an #if to handle both cases properly, otherwise the Python bindings
for either Python 2 or 3 will fail to build.

Python 3.x failure:

sigrok/core/classes_wrap.cpp: In function ‘PyObject* PyInit__classes()’:
sigrok/core/classes_wrap.cpp:59002:5: error: return-statement with no
value, in function returning ‘PyObject* {aka _object*}’ [-fpermissive]
     return;
     ^

Python 2.x failure:

In file included from /usr/include/dirent.h:244:0,
                 from /usr/include/glib-2.0/glib/gdir.h:32,
                 from /usr/include/glib-2.0/glib.h:45,
                 from /usr/include/pygobject-3.0/pygobject.h:7,
                 from sigrok/core/classes_wrap.cpp:3179:
sigrok/core/classes_wrap.cpp: In function ‘void init_classes()’:
sigrok/core/classes_wrap.cpp:59002:12: error: return-statement with a
value, in function returning 'void' [-fpermissive]
     return NULL;
            ^

bindings/python/sigrok/core/classes.i

index 2afe579124196e42f7782c95da099dc2e8c858f9..93e03ef29e5203d9e45035a22da2aa7e93815fc8 100644 (file)
@@ -75,7 +75,11 @@ typedef guint pyg_flags_type;
      */
     if (!GLib) {
         fprintf(stderr, "Import of gi.repository.GLib failed.\n");
+#if PY_VERSION_HEX >= 0x03000000
+        return NULL;
+#else
         return;
+#endif
     }
     IOChannel = (PyTypeObject *) PyObject_GetAttrString(GLib, "IOChannel");
     PollFD = (PyTypeObject *) PyObject_GetAttrString(GLib, "PollFD");