8000 Merge pull request #6077 from ndjensen/master · numpy/numpy@f09380a · GitHub
[go: up one dir, main page]

Skip to content

Commit f09380a

Browse files
committed
Merge pull request #6077 from ndjensen/master
ENH skip NPY_ALLOW_C_API for UFUNC_ERR_PRINT
2 parents eb7104e + 50f1fce commit f09380a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

numpy/core/src/umath/ufunc_object.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,17 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int *
105105
PyObject *pyfunc, *ret, *args;
106106
char *name = PyBytes_AS_STRING(PyTuple_GET_ITEM(errobj,0));
107107
char msg[100];
108-
NPY_ALLOW_C_API_DEF;
108+
109+
NPY_ALLOW_C_API_DEF
110+
111+
/* don't need C API for a simple print */
112+
if (method == UFUNC_ERR_PRINT) {
113+
if (*first) {
114+
fprintf(stderr, "Warning: %s encountered in %s\n", errtype, name);
115+
*first = 0;
116+
}
117+
return 0;
118+
}
109119

110120
NPY_ALLOW_C_API;
111121
switch(method) {
@@ -140,12 +150,6 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int *
140150
}
141151
Py_DECREF(ret);
142152
break;
143-
case UFUNC_ERR_PRINT:
144-
if (*first) {
145-
fprintf(stderr, "Warning: %s encountered in %s\n", errtype, name);
146-
*first = 0;
147-
}
148-
break;
149153
case UFUNC_ERR_LOG:
150154
if (first) {
151155
*first = 0;

0 commit comments

Comments
 (0)
0