8000 Merge pull request #29043 from charris/backport-29034 · numpy/numpy@819c089 · GitHub
[go: up one dir, main page]

Skip to content

Commit 819c089

Browse files
authored
Merge pull request #29043 from charris/backport-29034
BUG: Avoid compile errors in f2py modules
2 parents 5ba318d + 6277198 commit 819c089

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

numpy/f2py/cfuncs.py

Lines changed: 13 additions & 7 deletions
-
return 1;
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,12 @@ def errmess(s: str) -> None:
10471047
PyArray_ScalarAsCtype(obj, v);
10481048
return 1;
10491049
}
1050-
else if (PyArray_Check(obj) && PyArray_TYPE(obj) == NPY_LONGDOUBLE) {
1051-
(*v) = *((npy_longdouble *)PyArray_DATA(obj));
1052-
return 1;
1050+
else if (PyArray_Check(obj)) {
1051+
PyArrayObject *arr = (PyArrayObject *)obj;
1052+
if (PyArray_TYPE(arr) == NPY_LONGDOUBLE) {
1053+
(*v) = *((npy_longdouble *)PyArray_DATA(arr));
1054+
return 1;
1055+
}
10531056
}
10541057
}
10551058
if (double_from_pyobj(&d, obj, errmess)) {
@@ -1131,10 +1134,13 @@ def errmess(s: str) -> None:
11311134
PyArray_ScalarAsCtype(obj, v);
11321135
return 1;
11331136
}
1134-
else if (PyArray_Check(obj) && PyArray_TYPE(obj)==NPY_CLONGDOUBLE) {
1135-
(*v).r = npy_creall(*(((npy_clongdouble *)PyArray_DATA(obj))));
1136-
(*v).i = npy_cimagl(*(((npy_clongdouble *)PyArray_DATA(obj))));
1137
1137+
else if (PyArray_Check(obj)) {
1138+
PyArrayObject *arr = (PyArrayObject *)obj;
1139+
if (PyArray_TYPE(arr)==NPY_CLONGDOUBLE) {
1140+
(*v).r = npy_creall(*(((npy_clongdouble *)PyArray_DATA(arr))));
1141+
(*v).i = npy_cimagl(*(((npy_clongdouble *)PyArray_DATA(arr))));
1142+
return 1;
1143+
}
11381144
}
11391145
}
11401146
if (complex_double_from_pyobj(&cd,obj,errmess)) {

0 commit comments

Comments
 (0)
0