Skip to content

Commit 1df3f3b

Browse files
Merge pull request #62 from ngoldbaum/fix-promoter-error-handling
Fix error handling in add_promoter
2 parents a8744b1 + 48812f4 commit 1df3f3b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

stringdtype/stringdtype/src/umath.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,13 @@ add_promoter(PyObject *numpy, const char *ufunc_name,
364364
PyArray_DTypeMeta **dtypes)
365365
{
366366
PyObject *ufunc = PyObject_GetAttrString(numpy, ufunc_name);
367+
367368
if (ufunc == NULL) {
368369
return -1;
369370
}
370371

371372
PyObject *DType_tuple = PyTuple_Pack(3, dtypes[0], dtypes[1], dtypes[2]);
373+
372374
if (DType_tuple == NULL) {
373375
Py_DECREF(ufunc);
374376
return -1;
@@ -377,6 +379,12 @@ add_promoter(PyObject *numpy, const char *ufunc_name,
377379
PyObject *promoter_capsule = PyCapsule_New((void *)&default_ufunc_promoter,
378380
"numpy._ufunc_promoter", NULL);
379381

382+
if (promoter_capsule == NULL) {
383+
Py_DECREF(ufunc);
384+
Py_DECREF(DType_tuple);
385+
return -1;
386+
}
387+
380388
if (PyUFunc_AddPromoter(ufunc, DType_tuple, promoter_capsule) < 0) {
381389
Py_DECREF(promoter_capsule);
382390
Py_DECREF(DType_tuple);

0 commit comments

Comments
 (0)