Skip to content

Commit 3ad444b

Browse files
authored
Merge pull request numpy#17292 from charris/cleanup-remaining-pystring-macros
MAINT: Replace remaining PyString macros.
2 parents 48efb02 + c2dae48 commit 3ad444b

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

numpy/core/include/numpy/npy_common.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,10 @@ typedef Py_uintptr_t npy_uintp;
262262
#define constchar char
263263

264264
/* NPY_INTP_FMT Note:
265-
* Unlike the other NPY_*_FMT macros which are used with
266-
* PyOS_snprintf, NPY_INTP_FMT is used with PyErr_Format and
267-
* PyString_Format. These functions use different formatting
268-
* codes which are portably specified according to the Python
269-
* documentation. See ticket #1795.
265+
* Unlike the other NPY_*_FMT macros, which are used with PyOS_snprintf,
266+
* NPY_INTP_FMT is used with PyErr_Format and PyUnicode_FromFormat. Those
267+
* functions use different formatting codes that are portably specified
268+
* according to the Python documentation. See issue gh-2388.
270269
*/
271270
#if NPY_SIZEOF_PY_INTPTR_T == NPY_SIZEOF_INT
272271
#define NPY_INTP NPY_INT

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ array_scalar(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
20572057
Py_XDECREF(tmpobj);
20582058
return NULL;
20592059
}
2060-
if (PyString_GET_SIZE(obj) < typecode->elsize) {
2060+
if (PyBytes_GET_SIZE(obj) < typecode->elsize) {
20612061
PyErr_SetString(PyExc_ValueError,
20622062
"initialization string is too small");
20632063
Py_XDECREF(tmpobj);

numpy/core/src/multiarray/scalarapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ PyArray_DescrFromScalar(PyObject *sc)
613613
PyArray_DESCR_REPLACE(descr);
614614
type_num = descr->type_num;
615615
if (type_num == NPY_STRING) {
616-
descr->elsize = PyString_GET_SIZE(sc);
616+
descr->elsize = PyBytes_GET_SIZE(sc);
617617
}
618618
else if (type_num == NPY_UNICODE) {
619619
descr->elsize = PyUnicode_GET_LENGTH(sc) * 4;

numpy/f2py/cfuncs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@
438438
goto capi_fail;\\
439439
if (PyBytes_Check(rv_cb_str)) {\\
440440
str[len-1]='\\0';\\
441-
STRINGCOPYN((str),PyString_AS_STRING((PyBytesObject*)rv_cb_str),(len));\\
441+
STRINGCOPYN((str),PyBytes_AS_STRING((PyBytesObject*)rv_cb_str),(len));\\
442442
} else {\\
443443
PRINTPYOBJERR(rv_cb_str);\\
444444
PyErr_SetString(#modulename#_error,\"string object expected\");\\
@@ -675,9 +675,9 @@
675675
}
676676
if (tmp == NULL) goto capi_fail;
677677
if (*len == -1)
678-
*len = PyString_GET_SIZE(tmp);
678+
*len = PyBytes_GET_SIZE(tmp);
679679
STRINGMALLOC(*str,*len);
680-
STRINGCOPYN(*str,PyString_AS_STRING(tmp),*len+1);
680+
STRINGCOPYN(*str,PyBytes_AS_STRING(tmp),*len+1);
681681
Py_DECREF(tmp);
682682
return 1;
683683
capi_fail:

0 commit comments

Comments
 (0)