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
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-
return 1;
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy