diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-01-15 12:01:24 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-01-15 13:27:52 +0000 |
commit | 1b129a5981f025f50ca7b607e73fe508fbecde5a (patch) | |
tree | ccae96c400e9e8ed7e866ec01dd8d4ed08cc58e5 /numpy/linalg/umath_linalg.c.src | |
parent | e2921434a07c22714bbf242be5389c3056449863 (diff) | |
download | numpy-1b129a5981f025f50ca7b607e73fe508fbecde5a.tar.gz |
BUG: Add some missing C error handling
Diffstat (limited to 'numpy/linalg/umath_linalg.c.src')
-rw-r--r-- | numpy/linalg/umath_linalg.c.src | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/numpy/linalg/umath_linalg.c.src b/numpy/linalg/umath_linalg.c.src index 00ff6b7a8..21145a861 100644 --- a/numpy/linalg/umath_linalg.c.src +++ b/numpy/linalg/umath_linalg.c.src @@ -3590,7 +3590,7 @@ GUFUNC_DESCRIPTOR_t gufunc_descriptors [] = { } }; -static void +static int addUfuncs(PyObject *dictionary) { PyObject *f; int i; @@ -3609,12 +3609,19 @@ addUfuncs(PyObject *dictionary) { d->doc, 0, d->signature); - PyDict_SetItemString(dictionary, d->name, f); + if (f == NULL) { + return -1; + } #if 0 dump_ufunc_object((PyUFuncObject*) f); #endif + int ret = PyDict_SetItemString(dictionary, d->name, f); Py_DECREF(f); + if (ret < 0) { + return -1; + } } + return 0; } @@ -3654,17 +3661,22 @@ PyObject *PyInit__umath_linalg(void) import_ufunc(); d = PyModule_GetDict(m); + if (d == NULL) { + return NULL; + } version = PyString_FromString(umath_linalg_version_string); - PyDict_SetItemString(d, "__version__", version); + if (version == NULL) { + return NULL; + } + int ret = PyDict_SetItemString(d, "__version__", version); Py_DECREF(version); + if (ret < 0) { + return NULL; + } /* Load the ufunc operators into the module's namespace */ - addUfuncs(d); - - if (PyErr_Occurred()) { - PyErr_SetString(PyExc_RuntimeError, - "cannot load _umath_linalg module."); + if (addUfuncs(d) < 0) { return NULL; } |