Skip to content

Commit a7cae80

Browse files
committed
gh-155819: Add const qualifier to Py_buffer.format
1 parent 46c355f commit a7cae80

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

Include/pybuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ typedef struct {
2525
pointed to by strides in simple case.*/
2626
int readonly;
2727
int ndim;
28-
char *format;
28+
const char *format;
2929
Py_ssize_t *shape;
3030
Py_ssize_t *strides;
3131
Py_ssize_t *suboffsets;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The member ``format`` of ``Py_buffer`` is now of type ``const char *``
2+
rather than of type ``char *``. Contributed by High Performance Kernels
3+
LLC.

Modules/arraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,7 @@ array_buffer_getbuf(PyObject *op, Py_buffer *view, int flags)
29072907
view->format = NULL;
29082908
view->internal = NULL;
29092909
if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) {
2910-
view->format = (char *)self->ob_descr->typecode;
2910+
view->format = self->ob_descr->typecode;
29112911
}
29122912

29132913
self->ob_exports++;

Objects/memoryobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ cast_to_1D(PyMemoryViewObject *mv, PyObject *format)
13401340
goto out;
13411341
}
13421342

1343-
view->format = (char *)get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
1343+
view->format = get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
13441344
if (view->format == NULL) {
13451345
/* NOT_REACHED: get_native_fmtchar() already validates the format. */
13461346
PyErr_SetString(PyExc_RuntimeError,

0 commit comments

Comments
 (0)