| 585 | |
| 586 | |
| 587 | static void |
| 588 | raise_memory_error(int nd, npy_intp const *dims, PyArray_Descr *descr) |
| 589 | { |
| 590 | static PyObject *exc_type = NULL; |
| 591 | |
| 592 | npy_cache_import( |
| 593 | "numpy.core._exceptions", "_ArrayMemoryError", |
| 594 | &exc_type); |
| 595 | if (exc_type == NULL) { |
| 596 | goto fail; |
| 597 | } |
| 598 | |
| 599 | PyObject *shape = PyArray_IntTupleFromIntp(nd, dims); |
| 600 | if (shape == NULL) { |
| 601 | goto fail; |
| 602 | } |
| 603 | |
| 604 | /* produce an error object */ |
| 605 | PyObject *exc_value = PyTuple_Pack(2, shape, (PyObject *)descr); |
| 606 | Py_DECREF(shape); |
| 607 | if (exc_value == NULL){ |
| 608 | goto fail; |
| 609 | } |
| 610 | PyErr_SetObject(exc_type, exc_value); |
| 611 | Py_DECREF(exc_value); |
| 612 | return; |
| 613 | |
| 614 | fail: |
| 615 | /* we couldn't raise the formatted exception for some reason */ |
| 616 | PyErr_WriteUnraisable(NULL); |
| 617 | PyErr_NoMemory(); |
| 618 | } |
| 619 | |
| 620 | /* |
| 621 | * Generic new array creation routine. |
no test coverage detected