MCPcopy Create free account
hub / github.com/numpy/numpy / raise_memory_error

Function raise_memory_error

numpy/core/src/multiarray/ctors.c:587–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585
586
587static void
588raise_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
614fail:
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.

Callers 1

PyArray_NewFromDescr_intFunction · 0.85

Calls 2

npy_cache_importFunction · 0.85
PyArray_IntTupleFromIntpFunction · 0.85

Tested by

no test coverage detected