summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-02-03 11:07:34 -0800
committerEric Wieser <wieser.eric@gmail.com>2018-02-03 11:13:22 -0800
commit477bbc0b90fd41909cc2c14dfcbd5cf8ece902e6 (patch)
tree25597ded9f9683dae191bb7b7a7e2d40caa36b15 /numpy
parente3c74333eaf51bf8002d5bccfc97bd3fe8863e5c (diff)
downloadnumpy-477bbc0b90fd41909cc2c14dfcbd5cf8ece902e6.tar.gz
MAINT: Allow errors to escape from InitOperators
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/code_generators/generate_umath.py9
-rw-r--r--numpy/core/src/umath/umathmodule.c4
2 files changed, 10 insertions, 3 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py
index f418e4b47..ebcf864ea 100644
--- a/numpy/core/code_generators/generate_umath.py
+++ b/numpy/core/code_generators/generate_umath.py
@@ -1045,7 +1045,10 @@ def make_ufuncs(funcdict):
{name}_functions, {name}_data, {name}_signatures, {nloops},
{nin}, {nout}, {identity}, "{name}",
"{doc}", 0
- );""")
+ );
+ if (f == NULL) {{
+ return -1;
+ }}""")
mlist.append(fmt.format(
name=name, nloops=len(uf.type_descriptions),
nin=uf.nin, nout=uf.nout, identity=uf.identity, doc=docstring
@@ -1073,12 +1076,14 @@ def make_code(funcdict, filename):
%s
- static void
+ static int
InitOperators(PyObject *dictionary) {
PyObject *f;
%s
%s
+
+ return 0;
}
""") % (filename, code1, code2, code3)
return code
diff --git a/numpy/core/src/umath/umathmodule.c b/numpy/core/src/umath/umathmodule.c
index 1a6cee030..397c2f760 100644
--- a/numpy/core/src/umath/umathmodule.c
+++ b/numpy/core/src/umath/umathmodule.c
@@ -364,7 +364,9 @@ PyMODINIT_FUNC initumath(void)
Py_DECREF(s);
/* Load the ufunc operators into the array module's namespace */
- InitOperators(d);
+ if (InitOperators(d) < 0) {
+ goto err;
+ }
PyDict_SetItemString(d, "pi", s = PyFloat_FromDouble(NPY_PI));
Py_DECREF(s);