8000 MAINT: Allow errors to escape from InitOperators by eric-wieser · Pull Request #10516 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Allow errors to escape from InitOperators #10516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions numpy/core/code_generators/generate_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion numpy/core/src/umath/umathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
0