diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-01-16 04:48:06 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-16 04:48:06 +1100 |
commit | a5e5e51187d4476841503ce816924ea99936dba0 (patch) | |
tree | 1637a2927ab8fb1279b3978a8f808be72b4365ac /numpy/linalg/umath_linalg.c.src | |
parent | 9656e4c00d52d9583c577dbb892a090abaa3dd99 (diff) | |
parent | 1b129a5981f025f50ca7b607e73fe508fbecde5a (diff) | |
download | numpy-a5e5e51187d4476841503ce816924ea99936dba0.tar.gz |
Merge pull request #15333 from eric-wieser/use-PyDict_GetItemWithError
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 fa1396545..e66fc9916 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; } |