* Extracts some values from the global pyvals tuple. * all destinations may be NULL, in which case they are not retrieved * ref - should hold the global tuple * name - is the name of the ufunc (ufuncobj->name) * * bufsize - receives the buffer size to use * errmask - receives the bitmask for error handling * errobj - receives the python object to call with the error, * if an error
| 187 | * if an error handling method is 'call' |
| 188 | */ |
| 189 | NPY_NO_EXPORT int |
| 190 | _extract_pyvals(PyObject *ref, const char *name, int *bufsize, |
| 191 | int *errmask, PyObject **errobj) |
| 192 | { |
| 193 | PyObject *retval; |
| 194 | |
| 195 | /* default errobj case, skips dictionary lookup */ |
| 196 | if (ref == NULL) { |
| 197 | if (errmask) { |
| 198 | *errmask = UFUNC_ERR_DEFAULT; |
| 199 | } |
| 200 | if (errobj) { |
| 201 | *errobj = Py_BuildValue("NO", PyBytes_FromString(name), Py_None); |
| 202 | } |
| 203 | if (bufsize) { |
| 204 | *bufsize = NPY_BUFSIZE; |
| 205 | } |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | if (!PyList_Check(ref) || (PyList_GET_SIZE(ref)!=3)) { |
| 210 | PyErr_Format(PyExc_TypeError, |
| 211 | "%s must be a length 3 list.", UFUNC_PYVALS_NAME); |
| 212 | return -1; |
| 213 | } |
| 214 | |
| 215 | if (bufsize != NULL) { |
| 216 | *bufsize = PyLong_AsLong(PyList_GET_ITEM(ref, 0)); |
| 217 | if (error_converting(*bufsize)) { |
| 218 | return -1; |
| 219 | } |
| 220 | if ((*bufsize < NPY_MIN_BUFSIZE) || |
| 221 | (*bufsize > NPY_MAX_BUFSIZE) || |
| 222 | (*bufsize % 16 != 0)) { |
| 223 | PyErr_Format(PyExc_ValueError, |
| 224 | "buffer size (%d) is not in range " |
| 225 | "(%"NPY_INTP_FMT" - %"NPY_INTP_FMT") or not a multiple of 16", |
| 226 | *bufsize, (npy_intp) NPY_MIN_BUFSIZE, |
| 227 | (npy_intp) NPY_MAX_BUFSIZE); |
| 228 | return -1; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | if (errmask != NULL) { |
| 233 | *errmask = PyLong_AsLong(PyList_GET_ITEM(ref, 1)); |
| 234 | if (*errmask < 0) { |
| 235 | if (PyErr_Occurred()) { |
| 236 | return -1; |
| 237 | } |
| 238 | PyErr_Format(PyExc_ValueError, |
| 239 | "invalid error mask (%d)", |
| 240 | *errmask); |
| 241 | return -1; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | if (errobj != NULL) { |
| 246 | *errobj = NULL; |
no outgoing calls
no test coverage detected