Skip to content

Commit

Permalink
py3 vs py2 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Mar 30, 2018
1 parent 29a8903 commit 7049e9d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/python/io/NumpyReader.cpp
Expand Up @@ -242,7 +242,13 @@ void NumpyReader::prepareFieldsArray(PointLayoutPtr layout)
PyObject* pname = PyList_GetItem(names, i);
if (!pname)
throw pdal::pdal_error(plang::getTraceback());
const char* cname = PyString_AsString(pname);

const char* cname(0);
#if PY_MAJOR_VERSION >= 3
cname = PyBytes_AsString(PyUnicode_AsUTF8String(pname));
#else
cname = PyString_AsString(pname);
#endif
std::string name(cname);

PyObject* tup = PyList_GetItem(values, i);
Expand All @@ -257,7 +263,7 @@ void NumpyReader::prepareFieldsArray(PointLayoutPtr layout)
if (!offset_o)
throw pdal::pdal_error(plang::getTraceback());

long offset = PyInt_AsLong(offset_o);
long offset = PyLong_AsLong(offset_o);

PyArray_Descr* dtype = (PyArray_Descr*)dt;

Expand Down

0 comments on commit 7049e9d

Please sign in to comment.