summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-04-12 11:58:27 (GMT)
committerGitHub <noreply@github.com>2020-04-12 11:58:27 (GMT)
commit8f87eefe7f0576c05c488874eb9601a7a87c7312 (patch)
tree10ea36d1f702ae9e8bc34bcc88588868706948f6 /Objects
parent3e0dd3730b5eff7e9ae6fb921aa77cd26efc9e3a (diff)
downloadcpython-8f87eefe7f0576c05c488874eb9601a7a87c7312.zip
cpython-8f87eefe7f0576c05c488874eb9601a7a87c7312.tar.gz
cpython-8f87eefe7f0576c05c488874eb9601a7a87c7312.tar.bz2
bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. (GH-19472)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c15
-rw-r--r--Objects/fileobject.c2
-rw-r--r--Objects/longobject.c2
-rw-r--r--Objects/stringlib/join.h4
-rw-r--r--Objects/unicodeobject.c6
5 files changed, 15 insertions, 14 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 987d98d..7be075b 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -1598,7 +1598,7 @@ bytes_subscript(PyBytesObject* self, PyObject* item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, i;
size_t cur;
- char* source_buf;
+ const char* source_buf;
char* result_buf;
PyObject* result;
@@ -1863,7 +1863,7 @@ Py_LOCAL_INLINE(PyObject *)
do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
{
Py_buffer vsep;
- char *s = PyBytes_AS_STRING(self);
+ const char *s = PyBytes_AS_STRING(self);
Py_ssize_t len = PyBytes_GET_SIZE(self);
char *sep;
Py_ssize_t seplen;
@@ -1903,7 +1903,7 @@ do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
Py_LOCAL_INLINE(PyObject *)
do_strip(PyBytesObject *self, int striptype)
{
- char *s = PyBytes_AS_STRING(self);
+ const char *s = PyBytes_AS_STRING(self);
Py_ssize_t len = PyBytes_GET_SIZE(self), i, j;
i = 0;
@@ -2020,7 +2020,8 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table,
PyObject *deletechars)
/*[clinic end generated code: output=43be3437f1956211 input=0ecdf159f654233c]*/
{
- char *input, *output;
+ const char *input;
+ char *output;
Py_buffer table_view = {NULL, NULL};
Py_buffer del_table_view = {NULL, NULL};
const char *table_chars;
@@ -2371,7 +2372,7 @@ static PyObject *
bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep)
/*[clinic end generated code: output=1f134da504064139 input=f1238d3455990218]*/
{
- char* argbuf = PyBytes_AS_STRING(self);
+ const char *argbuf = PyBytes_AS_STRING(self);
Py_ssize_t arglen = PyBytes_GET_SIZE(self);
return _Py_strhex_with_sep(argbuf, arglen, sep, bytes_per_sep);
}
@@ -3188,7 +3189,7 @@ _PyBytesWriter_AsString(_PyBytesWriter *writer)
Py_LOCAL_INLINE(Py_ssize_t)
_PyBytesWriter_GetSize(_PyBytesWriter *writer, char *str)
{
- char *start = _PyBytesWriter_AsString(writer);
+ const char *start = _PyBytesWriter_AsString(writer);
assert(str != NULL);
assert(str >= start);
assert(str - start <= writer->allocated);
@@ -3199,7 +3200,7 @@ _PyBytesWriter_GetSize(_PyBytesWriter *writer, char *str)
Py_LOCAL_INLINE(int)
_PyBytesWriter_CheckConsistency(_PyBytesWriter *writer, char *str)
{
- char *start, *end;
+ const char *start, *end;
if (writer->use_small_buffer) {
assert(writer->buffer == NULL);
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 840d17b..b8ec56e 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -76,7 +76,7 @@ PyFile_GetLine(PyObject *f, int n)
}
if (n < 0 && result != NULL && PyBytes_Check(result)) {
- char *s = PyBytes_AS_STRING(result);
+ const char *s = PyBytes_AS_STRING(result);
Py_ssize_t len = PyBytes_GET_SIZE(result);
if (len == 0) {
Py_DECREF(result);
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 5d225cb..a66e1c4 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -5071,7 +5071,7 @@ long_new_impl(PyTypeObject *type, PyObject *x, PyObject *obase)
if (PyUnicode_Check(x))
return PyLong_FromUnicodeObject(x, (int)base);
else if (PyByteArray_Check(x) || PyBytes_Check(x)) {
- char *string;
+ const char *string;
if (PyByteArray_Check(x))
string = PyByteArray_AS_STRING(x);
else
diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h
index 8ad598a..53bcbde 100644
--- a/Objects/stringlib/join.h
+++ b/Objects/stringlib/join.h
@@ -7,8 +7,8 @@
Py_LOCAL_INLINE(PyObject *)
STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable)
{
- char *sepstr = STRINGLIB_STR(sep);
- const Py_ssize_t seplen = STRINGLIB_LEN(sep);
+ const char *sepstr = STRINGLIB_STR(sep);
+ Py_ssize_t seplen = STRINGLIB_LEN(sep);
PyObject *res = NULL;
char *p;
Py_ssize_t seqlen = 0;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 3c79feb..7f39022 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3887,7 +3887,7 @@ PyUnicode_FSConverter(PyObject* arg, void* addr)
PyObject *path = NULL;
PyObject *output = NULL;
Py_ssize_t size;
- void *data;
+ const char *data;
if (arg == NULL) {
Py_DECREF(*(PyObject**)addr);
*(PyObject**)addr = NULL;
@@ -4718,7 +4718,7 @@ _PyUnicode_EncodeUTF7(PyObject *str,
unsigned int base64bits = 0;
unsigned long base64buffer = 0;
char * out;
- char * start;
+ const char * start;
if (PyUnicode_READY(str) == -1)
return NULL;
@@ -5446,7 +5446,7 @@ unicode_fill_utf8(PyObject *unicode)
return -1;
}
- char *start = writer.use_small_buffer ? writer.small_buffer :
+ const char *start = writer.use_small_buffer ? writer.small_buffer :
PyBytes_AS_STRING(writer.buffer);
Py_ssize_t len = end - start;