| 3646 | } |
| 3647 | |
| 3648 | static PyObject * |
| 3649 | descr_subscript(PyArray_Descr *self, PyObject *op) |
| 3650 | { |
| 3651 | if (_check_has_fields(self) < 0) { |
| 3652 | return NULL; |
| 3653 | } |
| 3654 | |
| 3655 | if (PyUnicode_Check(op)) { |
| 3656 | return _subscript_by_name(self, op); |
| 3657 | } |
| 3658 | else if (_is_list_of_strings(op)) { |
| 3659 | return (PyObject *)arraydescr_field_subset_view(self, op); |
| 3660 | } |
| 3661 | else { |
| 3662 | Py_ssize_t i = PyArray_PyIntAsIntp(op); |
| 3663 | if (error_converting(i)) { |
| 3664 | /* if converting to an int gives a type error, adjust the message */ |
| 3665 | PyObject *err = PyErr_Occurred(); |
| 3666 | if (PyErr_GivenExceptionMatches(err, PyExc_TypeError)) { |
| 3667 | PyErr_SetString(PyExc_TypeError, |
| 3668 | "Field key must be an integer field offset, " |
| 3669 | "single field name, or list of field names."); |
| 3670 | } |
| 3671 | return NULL; |
| 3672 | } |
| 3673 | return _subscript_by_index(self, i); |
| 3674 | } |
| 3675 | } |
| 3676 | |
| 3677 | static PySequenceMethods descr_as_sequence = { |
| 3678 | (lenfunc) descr_length, /* sq_length */ |
nothing calls this directly
no test coverage detected