diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2018-02-03 19:08:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-03 19:08:44 -0700 |
| commit | ffe8d7e0f55b814a63840507d932d8b58c601c91 (patch) | |
| tree | 68958957de496873b23c7e31d4327068545e2dc5 | |
| parent | 7210768d8da23cea34c2f2cf05cdfb8837542e3c (diff) | |
| parent | 477bbc0b90fd41909cc2c14dfcbd5cf8ece902e6 (diff) | |
| download | numpy-ffe8d7e0f55b814a63840507d932d8b58c601c91.tar.gz | |
Merge pull request #10516 from eric-wieser/generate_umath-error-handle
MAINT: Allow errors to escape from InitOperators
| -rw-r--r-- | numpy/core/code_generators/generate_umath.py | 9 | ||||
| -rw-r--r-- | numpy/core/src/umath/umathmodule.c | 4 |
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); |
