diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2020-09-30 16:56:08 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2020-09-30 17:49:02 -0600 |
commit | b8b9b56a8112abd56b33a4dcdbfa9ed651c50e0d (patch) | |
tree | dfdae6c1cf272ffe173276f464f30b46971f37c5 | |
parent | fc6b5916dc261cc8deb953a0ca85828ddfff36cc (diff) | |
download | numpy-b8b9b56a8112abd56b33a4dcdbfa9ed651c50e0d.tar.gz |
MAINT: Replace PyUString_ConcatAndDel in array_assign.c
-rw-r--r-- | numpy/core/src/common/array_assign.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/numpy/core/src/common/array_assign.c b/numpy/core/src/common/array_assign.c index 67abcae24..c55f6bdb4 100644 --- a/numpy/core/src/common/array_assign.c +++ b/numpy/core/src/common/array_assign.c @@ -64,19 +64,22 @@ broadcast_strides(int ndim, npy_intp const *shape, return 0; broadcast_error: { - PyObject *errmsg; - - errmsg = PyUnicode_FromFormat("could not broadcast %s from shape ", - strides_name); - PyUString_ConcatAndDel(&errmsg, - build_shape_string(strides_ndim, strides_shape)); - PyUString_ConcatAndDel(&errmsg, - PyUnicode_FromString(" into shape ")); - PyUString_ConcatAndDel(&errmsg, - build_shape_string(ndim, shape)); - PyErr_SetObject(PyExc_ValueError, errmsg); - Py_DECREF(errmsg); + PyObject *shape1 = convert_shape_to_string(strides_ndim, + strides_shape, ""); + if (shape1 == NULL) { + return -1; + } + PyObject *shape2 = convert_shape_to_string(ndim, shape, ""); + if (shape2 == NULL) { + Py_DECREF(shape1); + return -1; + } + PyErr_Format(PyExc_ValueError, + "could not broadcast %s from shape %S into shape %S", + strides_name, shape1, shape2); + Py_DECREF(shape1); + Py_DECREF(shape2); return -1; } } |