[TD]fix Py2 errors

This commit is contained in:
wandererfan
2019-12-16 07:21:14 -05:00
committed by WandererFan
parent a04d0f2574
commit 3186d4753e

View File

@@ -333,11 +333,7 @@ void CenterLinePy::setExtension(Py::Float arg)
Py::Boolean CenterLinePy::getFlip(void) const
{
bool flip = getCenterLinePtr()->getFlip();
if (flip) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
}
return Py::Boolean(flip);
}
void CenterLinePy::setFlip(Py::Boolean arg)
@@ -384,10 +380,18 @@ void CenterLinePy::setEdges(Py::Object arg)
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
const char* utf8 = PyUnicode_AsUTF8(item);
std::string ssTemp(utf8);
temp.push_back(ssTemp);
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
#else
if (PyString_Check(item)) {
std::string s = PyString_AsString(item); //py2 only!!!
temp.push_back(s);
}
#endif
}
cl->m_edges = temp;
} else {
@@ -422,10 +426,18 @@ void CenterLinePy::setFaces(Py::Object arg)
int tSize = (int) PyList_Size(pList);
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
const char* utf8 = PyUnicode_AsUTF8(item);
std::string ssTemp(utf8);
temp.push_back(ssTemp);
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
#else
if (PyString_Check(item)) {
std::string s = PyString_AsString(item); //py2 only!!!
temp.push_back(s);
}
#endif
}
cl->m_faces = temp;
} else {
@@ -462,9 +474,17 @@ void CenterLinePy::setPoints(Py::Object arg)
int i = 0;
for ( ; i < tSize; i++) {
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
const char* utf8 = PyUnicode_AsUTF8(item);
std::string ssTemp(utf8);
temp.push_back(ssTemp);
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(item)) {
std::string s = PyUnicode_AsUTF8(item); //py3 only!!!
temp.push_back(s);
}
#else
if (PyString_Check(item)) {
std::string s = PyString_AsString(item); //py2 only!!!
temp.push_back(s);
}
#endif
}
cl->m_verts = temp;
} else {