File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -831,7 +831,12 @@ logical_ufunc_promoter(PyUFuncObject *NPY_UNUSED(ufunc),
831831 PyArray_DTypeMeta * op_dtypes [], PyArray_DTypeMeta * signature [],
832832 PyArray_DTypeMeta * new_op_dtypes [])
833833{
834- /* If we find any object at all, we currently force to object */
834+ /*
835+ * If we find any object DType at all, we currently force to object.
836+ * However, if the output is specified and not object, there is no point,
837+ * it should be just as well to cast the input rather than doing the
838+ * unsafe out cast.
839+ */
835840 int force_object = 0 ;
836841
837842 for (int i = 0 ; i < 3 ; i ++ ) {
@@ -852,7 +857,9 @@ logical_ufunc_promoter(PyUFuncObject *NPY_UNUSED(ufunc),
852857 }
853858 new_op_dtypes [i ] = item ;
854859 }
855- if (!force_object ) {
860+
861+ if (!force_object || (op_dtypes [2 ] != NULL
862+ && op_dtypes [2 ]-> type_num != NPY_OBJECT )) {
856863 return 0 ;
857864 }
858865 /* Actually, we have to use the OBJECT loop after all, set all we can
You can’t perform that action at this time.
0 commit comments