Jordan Rupprecht
2018-09-20 18:05:56 UTC
Casting is fine if Py_ssize_t == int, but not when Py_ssize_t == long.
Signed-off-by: Jordan Rupprecht <***@google.com>
---
python/ftdi1.i | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/python/ftdi1.i b/python/ftdi1.i
index 93793f8..d53ebb0 100644
--- a/python/ftdi1.i
+++ b/python/ftdi1.i
@@ -22,11 +22,13 @@ inline PyObject* charp2str(const char *v_, long len)
inline char * str2charp_size(PyObject* pyObj, int * size)
{
char * v_ = 0;
+ Py_ssize_t len = 0;
#if PY_MAJOR_VERSION >= 3
- PyBytes_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+ PyBytes_AsStringAndSize(pyObj, &v_, &len);
#else
- PyString_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+ PyString_AsStringAndSize(pyObj, &v_, &len);
#endif
+ *size = len;
return v_;
}
%}
Signed-off-by: Jordan Rupprecht <***@google.com>
---
python/ftdi1.i | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/python/ftdi1.i b/python/ftdi1.i
index 93793f8..d53ebb0 100644
--- a/python/ftdi1.i
+++ b/python/ftdi1.i
@@ -22,11 +22,13 @@ inline PyObject* charp2str(const char *v_, long len)
inline char * str2charp_size(PyObject* pyObj, int * size)
{
char * v_ = 0;
+ Py_ssize_t len = 0;
#if PY_MAJOR_VERSION >= 3
- PyBytes_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+ PyBytes_AsStringAndSize(pyObj, &v_, &len);
#else
- PyString_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+ PyString_AsStringAndSize(pyObj, &v_, &len);
#endif
+ *size = len;
return v_;
}
%}
--
2.19.0.444.g18242da7ef-goog
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+***@developer.intra2net.com
2.19.0.444.g18242da7ef-goog
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+***@developer.intra2net.com