Commit 9538b5ea authored by Joseph Weston's avatar Joseph Weston
Browse files

add int and string conversion

Mostly change string -> unicode, except in one instance where we
want to have bytes (pickling/unpickling)
parent 3b8e5d2f
......@@ -1640,7 +1640,7 @@ PyObject *reduce(PyObject *self_, PyObject*)
for (int i=0; i < ndim; ++i)
PyTuple_SET_ITEM(pyshape, i, PyInt_FromSize_t(shape[i]));
PyObject *format = PyInt_FromLong(format_by_dtype[int(get_dtype(self_))]);
PyObject *data = PyString_FromStringAndSize((char*)self->data(),
PyObject *data = PyBytes_FromStringAndSize((char*)self->data(),
size_in_bytes);
PyTuple_SET_ITEM(result, 0, reconstruct);
......
......@@ -10,8 +10,21 @@
#define CONVERSION_HH
#if PY_MAJOR_VERSION >= 3
// numeric types
#define PyInt_Type PyLong_Type
#define PyInt_FromLong PyLong_FromLong
#define PyInt_AsLong PyLong_AsLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_Check PyLong_Check
// string types
#define PyString_FromString PyUnicode_FromString
#define PyString_AsString PyUnicode_AsUnicode
#define PyString_FromStringAndSize PyUnicode_FromStringAndSize
#define PyString_InternFromString PyUnicode_InternFromString
#define PyString_Check(p) (PyUnicode_Check(p) || PyBytes_Check(p))
#else // Python 2.x
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#endif
#include <complex>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment