Browse Source

Be less anal--use PyNumber instead of PyLong

Adam Johnson 13 years ago
parent
commit
eeaae57cc3
  1. 10
      Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp

10
Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp

@ -77,24 +77,24 @@ PYTHON_INIT_DEFINITION(ptPlayer, args, keywords)
PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)"); PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)");
PYTHON_RETURN_INIT_ERROR; PYTHON_RETURN_INIT_ERROR;
} }
if (!(PyLong_Check(thirdObj) && PyFloat_Check(fourthObj))) if (!(PyNumber_Check(thirdObj) && PyFloat_Check(fourthObj)))
{ {
delete[] name; delete[] name;
PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)"); PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)");
PYTHON_RETURN_INIT_ERROR; PYTHON_RETURN_INIT_ERROR;
} }
pid = PyLong_AsUnsignedLong(thirdObj); pid = PyNumber_AsSsize_t(thirdObj, NULL);
distSeq = (float)PyFloat_AsDouble(fourthObj); distSeq = (float)PyFloat_AsDouble(fourthObj);
} else if (name = PyString_AsStringEx(firstObj)){ } else if (name = PyString_AsStringEx(firstObj)) {
if (!PyLong_Check(secondObj) || thirdObj || fourthObj) if (!PyNumber_Check(secondObj) || thirdObj || fourthObj)
{ {
delete[] name; delete[] name;
PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)"); PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)");
PYTHON_RETURN_INIT_ERROR; PYTHON_RETURN_INIT_ERROR;
} }
pid = PyLong_AsUnsignedLong(secondObj); pid = PyNumber_AsSsize_t(secondObj, NULL);
} else { } else {
PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)"); PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)");
PYTHON_RETURN_INIT_ERROR; PYTHON_RETURN_INIT_ERROR;

Loading…
Cancel
Save