]> sigrok.org Git - libsigrok.git/commitdiff
python: fix cdata to work with Python 3.x.
authorMartin Ling <redacted>
Wed, 17 Apr 2013 14:38:33 +0000 (15:38 +0100)
committerMartin Ling <redacted>
Wed, 17 Apr 2013 14:39:13 +0000 (15:39 +0100)
bindings/python/sigrok/core/lowlevel.i
bindings/swig/libsigrok.i

index 28abd50d7850ee8cb280adf5c74ca93835910955..32695f68a3edd602b9b1ac077b105eb2bdcfabbd 100644 (file)
@@ -69,6 +69,17 @@ int sr_session_datafeed_python_callback_add(PyObject *cb)
     }
 }
 
+PyObject *cdata(const void *data, unsigned long size)
+{
+#if PY_MAJOR_VERSION < 3
+    return PyString_FromStringAndSize(data, size);
+#else
+    return PyBytes_FromStringAndSize(data, size);
+#endif
+}
+
 %}
 
 int sr_session_datafeed_python_callback_add(PyObject *cb);
+
+PyObject *cdata(const void *data, unsigned long size);
index b216a31af0efab734bda0102049adc38871e6d21..bbabdf2e3cd5bb184e98849a876df17467842c22 100644 (file)
@@ -19,7 +19,6 @@
 
 %include "cpointer.i"
 %include "carrays.i"
-%include "cdata.i"
 %include "stdint.i"
 
 %{