NUMPY_API Set a subset of bytes from each element of the array steals reference to dtype, must not be NULL */
| 465 | steals reference to dtype, must not be NULL |
| 466 | */ |
| 467 | NPY_NO_EXPORT int |
| 468 | PyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype, |
| 469 | int offset, PyObject *val) |
| 470 | { |
| 471 | PyObject *ret = NULL; |
| 472 | int retval = 0; |
| 473 | |
| 474 | if (self == NULL) { |
| 475 | PyErr_SetString(PyExc_ValueError, |
| 476 | "self is NULL in PyArray_SetField"); |
| 477 | return -1; |
| 478 | } |
| 479 | |
| 480 | if (dtype == NULL) { |
| 481 | PyErr_SetString(PyExc_ValueError, |
| 482 | "dtype is NULL in PyArray_SetField"); |
| 483 | return -1; |
| 484 | } |
| 485 | |
| 486 | if (PyArray_FailUnlessWriteable(self, "assignment destination") < 0) { |
| 487 | Py_DECREF(dtype); |
| 488 | return -1; |
| 489 | } |
| 490 | |
| 491 | /* getfield returns a view we can write to */ |
| 492 | ret = PyArray_GetField(self, dtype, offset); |
| 493 | if (ret == NULL) { |
| 494 | return -1; |
| 495 | } |
| 496 | |
| 497 | retval = PyArray_CopyObject((PyArrayObject *)ret, val); |
| 498 | Py_DECREF(ret); |
| 499 | return retval; |
| 500 | } |
| 501 | |
| 502 | static PyObject * |
| 503 | array_setfield(PyArrayObject *self, PyObject *args, PyObject *kwds) |
no test coverage detected