@@ -6096,6 +6096,7 @@ ufunc_at__slow_iter(PyUFuncObject *ufunc, NPY_ARRAYMETHOD_FLAGS flags,
6096
6096
-1 , NULL , NULL , buffersize );
6097
6097
6098
6098
if (iter_buffer == NULL ) {
6099
+ /* will fail only on memory allocation errors */
6099
6100
for (int i = 0 ; i < 3 ; i ++ ) {
6100
6101
Py_XDECREF (array_operands [i ]);
6101
6102
}
@@ -6104,6 +6105,7 @@ ufunc_at__slow_iter(PyUFuncObject *ufunc, NPY_ARRAYMETHOD_FLAGS flags,
6104
6105
6105
6106
iternext = NpyIter_GetIterNext (iter_buffer , NULL );
6106
6107
if (iternext == NULL ) {
6108
+ /* can not really happen, iter_buffer creation is tightly controlled */
6107
6109
NpyIter_Deallocate (iter_buffer );
6108
6110
for (int i = 0 ; i < 3 ; i ++ ) {
6109
6111
Py_XDECREF (array_operands [i ]);
@@ -6185,7 +6187,7 @@ ufunc_at__slow_iter(PyUFuncObject *ufunc, NPY_ARRAYMETHOD_FLAGS flags,
6185
6187
NpyIter_Deallocate (iter_buffer );
6186
6188
for (int i = 0 ; i < 3 ; i ++ ) {
6187
6189
Py_XDECREF (array_operands [i ]);
6188
- }
6190
+ }
6189
6191
return res ;
6190
6192
}
6191
6193
@@ -6249,6 +6251,12 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
6249
6251
"second operand needed for ufunc" );
6250
6252
return NULL ;
6251
6253
}
6254
+
6255
+ if (ufunc -> nin == 1 && op2 != NULL ) {
6256
+ PyErr_SetString (PyExc_ValueError ,
6257
+ "second operand provided when ufunc is unary" );
6258
+ return NULL ;
6259
+ }
6252
6260
errval = PyUFunc_CheckOverride (ufunc , "at" ,
6253
6261
args , NULL , NULL , 0 , NULL , & override );
6254
6262
@@ -6299,6 +6307,7 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
6299
6307
if ((iter -> subspace != NULL ) && (iter -> consec )) {
6300
6308
PyArray_MapIterSwapAxes (iter , & op2_array , 0 );
6301
6309
if (op2_array == NULL ) {
6310
+ /* only on memory allocation failure */
6302
6311
goto fail ;
6303
6312
}
6304
6313
}
@@ -6314,13 +6323,16 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
6314
6323
if ((iter2 = (PyArrayIterObject * )\
6315
6324
PyArray_BroadcastToShape ((PyObject * )op2_array ,
6316
6325
iter -> dimensions , iter -> nd ))== NULL ) {
6326
+ /* only on memory allocation failures */
6317
6327
goto fail ;
6318
6328
}
6319
6329
}
6320
6330
6321
6331
PyArrayMethodObject * ufuncimpl = NULL ;
6322
6332
6323
6333
{
6334
+ /* Do all the dtype handling and find the correct ufuncimpl */
6335
+
6324
6336
PyArrayObject * tmp_operands [3 ] = {NULL , NULL , NULL };
6325
6337
PyArray_DTypeMeta * signature [3 ] = {NULL , NULL , NULL };
6326
6338
PyArray_DTypeMeta * operand_DTypes [3 ] = {NULL , NULL , NULL };
@@ -6346,7 +6358,6 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
6346
6358
operand_DTypes [2 ] = operand_DTypes [0 ];
6347
6359
Py_INCREF (operand_DTypes [2 ]);
6348
6360
6349
- nop = 3 ;
6350
6361
if (allow_legacy_promotion && ((PyArray_NDIM (op1_array ) == 0 )
6351
6362
!= (PyArray_NDIM (op2_array ) == 0 ))) {
6352
6363
/* both are legacy and only one is 0-D: force legacy */
@@ -6358,7 +6369,6 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
6358
6369
operand_DTypes [1 ] = operand_DTypes [0 ];
6359
6370
Py_INCREF (operand_DTypes [1 ]);
6360
6371
tmp_operands [2 ] = NULL ;
6361
- nop = 2 ;
6362
6372
}
6363
6373
6364
6374
ufuncimpl = promote_and_get_ufuncimpl (ufunc , tmp_operands , signature ,
0 commit comments