Skip to content

Commit 76eefc1

Browse files
committed
MNT: Sebastian's comments
Signed-off-by: Iason Krommydas <[email protected]>
1 parent bc5ae14 commit 76eefc1

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎numpy/_core/code_generators/generate_umath.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,7 @@ def make_ufuncs(funcdict):
16141614
PyArray_DTypeMeta *dtype = PyArray_DTypeFromTypeNum({typenum});
16151615
PyObject *info = get_info_no_cast((PyUFuncObject *)f,
16161616
dtype, {count});
1617+
Py_DECREF(dtype);
16171618
if (info == NULL) {{
16181619
return -1;
16191620
}}
@@ -1627,6 +1628,7 @@ def make_ufuncs(funcdict):
16271628
PyErr_SetString(PyExc_RuntimeError,
16281629
"Not a PyArrayMethodObject in ufunc "
16291630
"{name} with {typenum}");
1631+
return -1;
16301632
}}
16311633
((PyArrayMethodObject*)info)->contiguous_indexed_loop =
16321634
{funcname};

‎numpy/_core/src/umath/dispatching.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,8 @@ install_logical_ufunc_promoter(PyObject *ufunc)
14411441

14421442
/*
14431443
* Return the PyArrayMethodObject or PyCapsule that matches a registered
1444-
* tuple of identical dtypes. Return a borrowed ref of the first match.
1444+
* tuple of identical dtypes, or Py_None if there is no match (NULL on error).
1445+
* The result is always a borrowed reference.
14451446
*/
14461447
NPY_NO_EXPORT PyObject *
14471448
get_info_no_cast(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtype,
@@ -1466,7 +1467,7 @@ get_info_no_cast(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtype,
14661467
Py_DECREF(info);
14671468
return result;
14681469
}
1469-
Py_RETURN_NONE;
1470+
return Py_None;
14701471
}
14711472

14721473
/*UFUNC_API

‎numpy/_core/src/umath/minmax.cpp‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
#include "loops.h"
2525
#include "minmax.h"
2626

27-
#include "loops_minmax.dispatch.h"
28-
2927

3028
/*
3129
* `get_reduction_loop` slot for `minimummaximum`: return the dedicated
3230
* (nout+1)->nout reduction loop for the resolved dtype.
3331
*/
32+
#include "loops_minmax.dispatch.h"
3433
static int
3534
minimummaximum_get_reduction_loop(
3635
PyArrayMethod_Context *context,
@@ -134,9 +133,6 @@ init_minimummaximum(PyObject *umath)
134133
goto fail;
135134
}
136135
if (info == Py_None || !PyObject_TypeCheck(info, &PyArrayMethod_Type)) {
137-
if (info == Py_None) {
138-
Py_DECREF(info);
139-
}
140136
PyErr_SetString(PyExc_RuntimeError,
141137
"internal NumPy error: minimummaximum loop not found");
142138
goto fail;

0 commit comments

Comments
 (0)