summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2020-09-11 07:28:20 -0600
committerCharles Harris <charlesr.harris@gmail.com>2020-09-11 08:17:39 -0600
commitc2dae48225b8b004fe68ae1875eecec4f4b758f1 (patch)
tree3f719aec77a847f91a94e269d0dea64643bd2d70
parent02798e4ce39ae7882b19a3fde209472b7411d48a (diff)
downloadnumpy-c2dae48225b8b004fe68ae1875eecec4f4b758f1.tar.gz
MAINT: Replace remaining PyString macros.
Replace remaining npy_3kcompat PyString macros with their definition. - PyString_AS_STRING -> PyBytes_AS_STRING - PyString_GET_SIZE -> PyBytes_GET_SIZE
-rw-r--r--numpy/core/include/numpy/npy_common.h9
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c2
-rw-r--r--numpy/core/src/multiarray/scalarapi.c2
-rw-r--r--numpy/f2py/cfuncs.py6
4 files changed, 9 insertions, 10 deletions
diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h
index 5706e0576..560b82912 100644
--- a/numpy/core/include/numpy/npy_common.h
+++ b/numpy/core/include/numpy/npy_common.h
@@ -262,11 +262,10 @@ typedef Py_uintptr_t npy_uintp;
#define constchar char
/* NPY_INTP_FMT Note:
- * Unlike the other NPY_*_FMT macros which are used with
- * PyOS_snprintf, NPY_INTP_FMT is used with PyErr_Format and
- * PyString_Format. These functions use different formatting
- * codes which are portably specified according to the Python
- * documentation. See ticket #1795.
+ * Unlike the other NPY_*_FMT macros, which are used with PyOS_snprintf,
+ * NPY_INTP_FMT is used with PyErr_Format and PyUnicode_FromFormat. Those
+ * functions use different formatting codes that are portably specified
+ * according to the Python documentation. See issue gh-2388.
*/
#if NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_INT
#define NPY_INTP NPY_INT
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 490a60393..f1d5ab694 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -2057,7 +2057,7 @@ array_scalar(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
Py_XDECREF(tmpobj);
return NULL;
}
- if (PyString_GET_SIZE(obj) < typecode->elsize) {
+ if (PyBytes_GET_SIZE(obj) < typecode->elsize) {
PyErr_SetString(PyExc_ValueError,
"initialization string is too small");
Py_XDECREF(tmpobj);
diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c
index b2f52f554..b918786f2 100644
--- a/numpy/core/src/multiarray/scalarapi.c
+++ b/numpy/core/src/multiarray/scalarapi.c
@@ -613,7 +613,7 @@ PyArray_DescrFromScalar(PyObject *sc)
PyArray_DESCR_REPLACE(descr);
type_num = descr->type_num;
if (type_num == NPY_STRING) {
- descr->elsize = PyString_GET_SIZE(sc);
+ descr->elsize = PyBytes_GET_SIZE(sc);
}
else if (type_num == NPY_UNICODE) {
descr->elsize = PyUnicode_GET_LENGTH(sc) * 4;
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py
index b3a734e3d..df4cbf367 100644
--- a/numpy/f2py/cfuncs.py
+++ b/numpy/f2py/cfuncs.py
@@ -438,7 +438,7 @@ cppmacros['GETSTRFROMPYTUPLE'] = """\
goto capi_fail;\\
if (PyBytes_Check(rv_cb_str)) {\\
str[len-1]='\\0';\\
- STRINGCOPYN((str),PyString_AS_STRING((PyBytesObject*)rv_cb_str),(len));\\
+ STRINGCOPYN((str),PyBytes_AS_STRING((PyBytesObject*)rv_cb_str),(len));\\
} else {\\
PRINTPYOBJERR(rv_cb_str);\\
PyErr_SetString(#modulename#_error,\"string object expected\");\\
@@ -675,9 +675,9 @@ fprintf(stderr,\"string_from_pyobj(str='%s',len=%d,inistr='%s',obj=%p)\\n\",(cha
}
if (tmp == NULL) goto capi_fail;
if (*len == -1)
- *len = PyString_GET_SIZE(tmp);
+ *len = PyBytes_GET_SIZE(tmp);
STRINGMALLOC(*str,*len);
- STRINGCOPYN(*str,PyString_AS_STRING(tmp),*len+1);
+ STRINGCOPYN(*str,PyBytes_AS_STRING(tmp),*len+1);
Py_DECREF(tmp);
return 1;
capi_fail: