From: Martin Ling Date: Wed, 17 Apr 2013 14:38:33 +0000 (+0100) Subject: python: fix cdata to work with Python 3.x. X-Git-Tag: dsupstream~110 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=08d59537c353c6980c5e9a0f8b0039f2ab5b0ba5;p=libsigrok.git python: fix cdata to work with Python 3.x. --- diff --git a/bindings/python/sigrok/core/lowlevel.i b/bindings/python/sigrok/core/lowlevel.i index 28abd50d..32695f68 100644 --- a/bindings/python/sigrok/core/lowlevel.i +++ b/bindings/python/sigrok/core/lowlevel.i @@ -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); diff --git a/bindings/swig/libsigrok.i b/bindings/swig/libsigrok.i index b216a31a..bbabdf2e 100644 --- a/bindings/swig/libsigrok.i +++ b/bindings/swig/libsigrok.i @@ -19,7 +19,6 @@ %include "cpointer.i" %include "carrays.i" -%include "cdata.i" %include "stdint.i" %{