summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2022-08-31 21:06:49 +0300
committerRalf Gommers <ralf.gommers@gmail.com>2022-08-31 21:10:36 +0300
commitc465c2941d10a57fb4dd8cb07454f9a4085620af (patch)
tree711ecf01f1762330241cf1de167a2ca99066b661
parent917335c6f1277e44c998c8475173ba66b4d409b5 (diff)
downloadnumpy-c465c2941d10a57fb4dd8cb07454f9a4085620af.tar.gz
MAINT: fix an incorrect pointer type usage in f2py
This was giving many warnings like this one in the SciPy build: ``` scipy/special/_specfunmodule.c: In function 'complex_double_from_pyobj': scipy/special/_specfunmodule.c:198:47: warning: passing argument 1 of 'PyArray_DATA' from incompatible pointer type [-Wincompatible-pointer-types] 198 | (*v).r = ((npy_cdouble *)PyArray_DATA(arr))->real; | ^~~ | | | PyObject * {aka struct _object *} In file included from /home/rgommers/code/numpy/numpy/core/include/numpy/ndarrayobject.h:12, from /home/rgommers/code/numpy/numpy/core/include/numpy/arrayobject.h:5, from /home/rgommers/code/numpy/numpy/f2py/src/fortranobject.h:16, from scipy/special/_specfunmodule.c:22: /home/rgommers/code/numpy/numpy/core/include/numpy/ndarraytypes.h:1524:29: note: expected 'PyArrayObject *' {aka 'struct tagPyArrayObject *'} but argument is of type 'PyObject *' {aka 'struct _object *'} 1524 | PyArray_DATA(PyArrayObject *arr) | ~~~~~~~~~~~~~~~^~~ ``` Fixing pointer mismatches is important for Pyodide/Emscripten.
-rw-r--r--numpy/f2py/cfuncs.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py
index d644ede8c..64d96c3c2 100644
--- a/numpy/f2py/cfuncs.py
+++ b/numpy/f2py/cfuncs.py
@@ -1146,12 +1146,12 @@ complex_double_from_pyobj(complex_double* v, PyObject *obj, const char *errmess)
return 1;
}
if (PyArray_CheckScalar(obj)) { /* 0-dim array or still array scalar */
- PyObject *arr;
+ PyArrayObject *arr;
if (PyArray_Check(obj)) {
- arr = PyArray_Cast((PyArrayObject *)obj, NPY_CDOUBLE);
+ arr = (PyArrayObject *)PyArray_Cast((PyArrayObject *)obj, NPY_CDOUBLE);
}
else {
- arr = PyArray_FromScalar(obj, PyArray_DescrFromType(NPY_CDOUBLE));
+ arr = (PyArrayObject *)PyArray_FromScalar(obj, PyArray_DescrFromType(NPY_CDOUBLE));
}
if (arr == NULL) {
return 0;