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

Function npyiter_dealloc

numpy/core/src/multiarray/nditer_pywrap.c:1135–1169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1133
1134
1135static void
1136npyiter_dealloc(NewNpyArrayIterObject *self)
1137{
1138 if (self->iter) {
1139 /* Store error, so that WriteUnraisable cannot clear an existing one */
1140 PyObject *exc, *val, *tb;
1141 PyErr_Fetch(&exc, &val, &tb);
1142 if (npyiter_has_writeback(self->iter)) {
1143 if (PyErr_WarnEx(PyExc_RuntimeWarning,
1144 "Temporary data has not been written back to one of the "
1145 "operands. Typically nditer is used as a context manager "
1146 "otherwise 'close' must be called before reading iteration "
1147 "results.", 1) < 0) {
1148 PyObject *s;
1149
1150 s = PyUnicode_FromString("npyiter_dealloc");
1151 if (s) {
1152 PyErr_WriteUnraisable(s);
1153 Py_DECREF(s);
1154 }
1155 else {
1156 PyErr_WriteUnraisable(Py_None);
1157 }
1158 }
1159 }
1160 if (!NpyIter_Deallocate(self->iter)) {
1161 PyErr_WriteUnraisable(Py_None);
1162 }
1163 self->iter = NULL;
1164 Py_XDECREF(self->nested_child);
1165 self->nested_child = NULL;
1166 PyErr_Restore(exc, val, tb);
1167 }
1168 Py_TYPE(self)->tp_free((PyObject*)self);
1169}
1170
1171static int
1172npyiter_resetbasepointers(NewNpyArrayIterObject *self)

Callers

nothing calls this directly

Calls 2

npyiter_has_writebackFunction · 0.85
NpyIter_DeallocateFunction · 0.85

Tested by

no test coverage detected