summaryrefslogtreecommitdiff
path: root/tools/swig/numpy.i
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2020-10-18 14:18:10 -0600
committerCharles Harris <charlesr.harris@gmail.com>2020-10-18 15:05:25 -0600
commitcf06cd41ba8bd49b3ada8aa333df8e562829247b (patch)
tree85fae9ed78814a08ff5c64a2ac5afae4147f60ae /tools/swig/numpy.i
parenta5aae4f4cd852b64f5f36e8c225895b3a2113c48 (diff)
downloadnumpy-cf06cd41ba8bd49b3ada8aa333df8e562829247b.tar.gz
MAINT: Cleanup swig for Python 3.
Replaces ``PyInt_Check`` and ``PyInt_AsLong`` in a few places.
Diffstat (limited to 'tools/swig/numpy.i')
-rw-r--r--tools/swig/numpy.i12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/swig/numpy.i b/tools/swig/numpy.i
index a2e7a335f..60930c098 100644
--- a/tools/swig/numpy.i
+++ b/tools/swig/numpy.i
@@ -115,7 +115,7 @@
if (py_obj == Py_None ) return "Python None" ;
if (PyCallable_Check(py_obj)) return "callable" ;
if (PyBytes_Check( py_obj)) return "string" ;
- if (PyInt_Check( py_obj)) return "int" ;
+ if (PyLong_Check( py_obj)) return "int" ;
if (PyFloat_Check( py_obj)) return "float" ;
if (PyDict_Check( py_obj)) return "dict" ;
if (PyList_Check( py_obj)) return "list" ;
@@ -2002,7 +2002,7 @@
(PyObject* array = NULL)
{
npy_intp dims[1];
- if (!PyInt_Check($input))
+ if (!PyLong_Check($input))
{
const char* typestring = pytype_string($input);
PyErr_Format(PyExc_TypeError,
@@ -2010,7 +2010,8 @@
typestring);
SWIG_fail;
}
- $2 = (DIM_TYPE) PyInt_AsLong($input);
+ $2 = (DIM_TYPE) PyLong_AsSsize_t($input);
+ if ($2 == -1 && PyErr_Occurred()) SWIG_fail;
dims[0] = (npy_intp) $2;
array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
if (!array) SWIG_fail;
@@ -2030,7 +2031,7 @@
(PyObject* array = NULL)
{
npy_intp dims[1];
- if (!PyInt_Check($input))
+ if (!PyLong_Check($input))
{
const char* typestring = pytype_string($input);
PyErr_Format(PyExc_TypeError,
@@ -2038,7 +2039,8 @@
typestring);
SWIG_fail;
}
- $1 = (DIM_TYPE) PyInt_AsLong($input);
+ $1 = (DIM_TYPE) PyLong_AsSsize_t($input);
+ if ($1 == -1 && PyErr_Occurred()) SWIG_fail;
dims[0] = (npy_intp) $1;
array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
if (!array) SWIG_fail;