diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2020-09-30 17:36:20 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2020-09-30 17:49:02 -0600 |
commit | 278ed3eb540529c5cb5dc30c317c9e4558c05c64 (patch) | |
tree | 8ffe5d338b19622c9fd486f14c7b26f09f37c8f0 | |
parent | b8b9b56a8112abd56b33a4dcdbfa9ed651c50e0d (diff) | |
download | numpy-278ed3eb540529c5cb5dc30c317c9e4558c05c64.tar.gz |
MAINT: Replace PyUString_ConcatAndDel in common.c.
-rw-r--r-- | numpy/core/src/multiarray/common.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c index 6af71f351..841ed799d 100644 --- a/numpy/core/src/multiarray/common.c +++ b/numpy/core/src/multiarray/common.c @@ -233,7 +233,6 @@ NPY_NO_EXPORT PyObject * convert_shape_to_string(npy_intp n, npy_intp const *vals, char *ending) { npy_intp i; - PyObject *ret, *tmp; /* * Negative dimension indicates "newaxis", which can @@ -245,14 +244,14 @@ convert_shape_to_string(npy_intp n, npy_intp const *vals, char *ending) if (i == n) { return PyUnicode_FromFormat("()%s", ending); } - else { - ret = PyUnicode_FromFormat("(%" NPY_INTP_FMT, vals[i++]); - if (ret == NULL) { - return NULL; - } - } + PyObject *ret = PyUnicode_FromFormat("%" NPY_INTP_FMT, vals[i++]); + if (ret == NULL) { + return NULL; + } for (; i < n; ++i) { + PyObject *tmp; + if (vals[i] < 0) { tmp = PyUnicode_FromString(",newaxis"); } @@ -264,19 +263,19 @@ convert_shape_to_string(npy_intp n, npy_intp const *vals, char *ending) return NULL; } - PyUString_ConcatAndDel(&ret, tmp); + Py_SETREF(ret, PyUnicode_Concat(ret, tmp)); + Py_DECREF(tmp); if (ret == NULL) { return NULL; } } if (i == 1) { - tmp = PyUnicode_FromFormat(",)%s", ending); + Py_SETREF(ret, PyUnicode_FromFormat("(%S,)%s", ret, ending)); } else { - tmp = PyUnicode_FromFormat(")%s", ending); + Py_SETREF(ret, PyUnicode_FromFormat("(%S)%s", ret, ending)); } - PyUString_ConcatAndDel(&ret, tmp); return ret; } |