| 564 | } |
| 565 | |
| 566 | static int |
| 567 | arrayflags_setitem(PyArrayFlagsObject *self, PyObject *ind, PyObject *item) |
| 568 | { |
| 569 | char *key; |
| 570 | char buf[16]; |
| 571 | int n; |
| 572 | if (PyUnicode_Check(ind)) { |
| 573 | PyObject *tmp_str; |
| 574 | tmp_str = PyUnicode_AsASCIIString(ind); |
| 575 | key = PyBytes_AS_STRING(tmp_str); |
| 576 | n = PyBytes_GET_SIZE(tmp_str); |
| 577 | if (n > 16) n = 16; |
| 578 | memcpy(buf, key, n); |
| 579 | Py_DECREF(tmp_str); |
| 580 | key = buf; |
| 581 | } |
| 582 | else if (PyBytes_Check(ind)) { |
| 583 | key = PyBytes_AS_STRING(ind); |
| 584 | n = PyBytes_GET_SIZE(ind); |
| 585 | } |
| 586 | else { |
| 587 | goto fail; |
| 588 | } |
| 589 | if (((n==9) && (strncmp(key, "WRITEABLE", n) == 0)) || |
| 590 | ((n==1) && (strncmp(key, "W", n) == 0))) { |
| 591 | return arrayflags_writeable_set(self, item, NULL); |
| 592 | } |
| 593 | else if (((n==7) && (strncmp(key, "ALIGNED", n) == 0)) || |
| 594 | ((n==1) && (strncmp(key, "A", n) == 0))) { |
| 595 | return arrayflags_aligned_set(self, item, NULL); |
| 596 | } |
| 597 | else if (((n==15) && (strncmp(key, "WRITEBACKIFCOPY", n) == 0)) || |
| 598 | ((n==1) && (strncmp(key, "X", n) == 0))) { |
| 599 | return arrayflags_writebackifcopy_set(self, item, NULL); |
| 600 | } |
| 601 | |
| 602 | fail: |
| 603 | PyErr_SetString(PyExc_KeyError, "Unknown flag"); |
| 604 | return -1; |
| 605 | } |
| 606 | |
| 607 | static char * |
| 608 | _torf_(int flags, int val) |
nothing calls this directly
no test coverage detected