8000 Merge pull request #9119 from SuperBo/master · ahaldane/numpy@d4eaa2c · GitHub
[go: up one dir, main page]

Skip to content

Commit d4eaa2c

Browse files
authored
Merge pull request numpy#9119 from SuperBo/master
BUG: Fix error handling on PyCapsule when initializing multiarraymodule
2 parents c610444 + b67796b commit d4eaa2c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4607,15 +4607,13 @@ PyMODINIT_FUNC initmultiarray(void) {
46074607
if (PyType_Ready(&NpyBusDayCalendar_Type) < 0) {
46084608
return RETVAL;
46094609
}
4610-
/* FIXME
4611-
* There is no error handling here
4612-
*/
4610+
46134611
c_api = NpyCapsule_FromVoidPtr((void *)PyArray_API, NULL);
4614-
PyDict_SetItemString(d, "_ARRAY_API", c_api);
4615-
Py_DECREF(c_api);
4616-
if (PyErr_Occurred()) {
4612+
if (c_api == NULL) {
46174613
goto err;
46184614
}
4615+
PyDict_SetItemString(d, "_ARRAY_API", c_api);
4616+
Py_DECREF(c_api);
46194617

46204618
/*
46214619
* PyExc_Exception should catch all the standard errors that are
@@ -4633,10 +4631,10 @@ PyMODINIT_FUNC initmultiarray(void) {
46334631
PyDict_SetItemString(d, "__version__", s);
46344632
Py_DECREF(s);
46354633

4636-
/* FIXME
4637-
* There is no error handling here
4638-
*/
46394634
s = NpyCapsule_FromVoidPtr((void *)_datetime_strings, NULL);
4635+
if (s == NULL) {
4636+
goto err;
4637+
}
46404638
PyDict_SetItemString(d, "DATETIMEUNITS", s);
46414639
Py_DECREF(s);
46424640

0 commit comments

Comments
 (0)
0