| 721 | } |
| 722 | |
| 723 | static int |
| 724 | npyrational_setitem(PyObject* item, void* data, void* arr) { |
| 725 | rational r; |
| 726 | if (PyRational_Check(item)) { |
| 727 | r = ((PyRational*)item)->r; |
| 728 | } |
| 729 | else { |
| 730 | long long n = PyLong_AsLongLong(item); |
| 731 | PyObject* y; |
| 732 | int eq; |
| 733 | if (error_converting(n)) { |
| 734 | return -1; |
| 735 | } |
| 736 | y = PyLong_FromLongLong(n); |
| 737 | if (!y) { |
| 738 | return -1; |
| 739 | } |
| 740 | eq = PyObject_RichCompareBool(item, y, Py_EQ); |
| 741 | Py_DECREF(y); |
| 742 | if (eq<0) { |
| 743 | return -1; |
| 744 | } |
| 745 | if (!eq) { |
| 746 | PyErr_Format(PyExc_TypeError, |
| 747 | "expected rational, got %s", item->ob_type->tp_name); |
| 748 | return -1; |
| 749 | } |
| 750 | r = make_rational_int(n); |
| 751 | } |
| 752 | memcpy(data, &r, sizeof(rational)); |
| 753 | return 0; |
| 754 | } |
| 755 | |
| 756 | static inline void |
| 757 | byteswap(npy_int32* x) { |
nothing calls this directly
no test coverage detected