diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-04-11 07:48:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 07:48:40 (GMT) |
commit | cd8295ff758891f21084a6a5ad3403d35dda38f7 (patch) | |
tree | a77f829dea34198a7f36658c6e22baf4bc0bf5f5 /Modules | |
parent | 7ec43a73092d43c6c95e7dd2669f49d54b57966f (diff) | |
download | cpython-cd8295ff758891f21084a6a5ad3403d35dda38f7.zip cpython-cd8295ff758891f21084a6a5ad3403d35dda38f7.tar.gz cpython-cd8295ff758891f21084a6a5ad3403d35dda38f7.tar.bz2 |
bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode data. (GH-19345)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_csv.c | 8 | ||||
-rw-r--r-- | Modules/_decimal/_decimal.c | 4 | ||||
-rw-r--r-- | Modules/_elementtree.c | 2 | ||||
-rw-r--r-- | Modules/_io/textio.c | 10 | ||||
-rw-r--r-- | Modules/_json.c | 14 | ||||
-rw-r--r-- | Modules/_operator.c | 2 | ||||
-rw-r--r-- | Modules/_pickle.c | 2 | ||||
-rw-r--r-- | Modules/_sqlite/connection.c | 2 | ||||
-rw-r--r-- | Modules/_sre.c | 12 | ||||
-rw-r--r-- | Modules/cjkcodecs/cjkcodecs.h | 2 | ||||
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 4 | ||||
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.h | 2 | ||||
-rw-r--r-- | Modules/pyexpat.c | 2 | ||||
-rw-r--r-- | Modules/sre.h | 14 | ||||
-rw-r--r-- | Modules/sre_lib.h | 28 | ||||
-rw-r--r-- | Modules/unicodedata.c | 6 |
16 files changed, 57 insertions, 57 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index 9c49715..950b0d7 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -789,7 +789,7 @@ Reader_iternext(ReaderObj *self) Py_UCS4 c; Py_ssize_t pos, linelen; unsigned int kind; - void *data; + const void *data; PyObject *lineobj; if (parse_reset(self) < 0) @@ -996,7 +996,7 @@ join_reset(WriterObj *self) * record length. */ static Py_ssize_t -join_append_data(WriterObj *self, unsigned int field_kind, void *field_data, +join_append_data(WriterObj *self, unsigned int field_kind, const void *field_data, Py_ssize_t field_len, int *quoted, int copy_phase) { @@ -1107,7 +1107,7 @@ static int join_append(WriterObj *self, PyObject *field, int quoted) { unsigned int field_kind = -1; - void *field_data = NULL; + const void *field_data = NULL; Py_ssize_t field_len = 0; Py_ssize_t rec_len; @@ -1139,7 +1139,7 @@ join_append_lineterminator(WriterObj *self) { Py_ssize_t terminator_len, i; unsigned int term_kind; - void *term_data; + const void *term_data; terminator_len = PyUnicode_GET_LENGTH(self->dialect->lineterminator); if (terminator_len == -1) diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index b36e309..cdc942f 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -1878,7 +1878,7 @@ dec_dealloc(PyObject *dec) /******************************************************************************/ Py_LOCAL_INLINE(int) -is_space(enum PyUnicode_Kind kind, void *data, Py_ssize_t pos) +is_space(enum PyUnicode_Kind kind, const void *data, Py_ssize_t pos) { Py_UCS4 ch = PyUnicode_READ(kind, data, pos); return Py_UNICODE_ISSPACE(ch); @@ -1896,7 +1896,7 @@ static char * numeric_as_ascii(const PyObject *u, int strip_ws, int ignore_underscores) { enum PyUnicode_Kind kind; - void *data; + const void *data; Py_UCS4 ch; char *res, *cp; Py_ssize_t j, len; diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 49c372d..c0c741e 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1132,7 +1132,7 @@ checkpath(PyObject* tag) if (PyUnicode_Check(tag)) { const Py_ssize_t len = PyUnicode_GET_LENGTH(tag); - void *data = PyUnicode_DATA(tag); + const void *data = PyUnicode_DATA(tag); unsigned int kind = PyUnicode_KIND(tag); if (len >= 3 && PyUnicode_READ(kind, data, 0) == '{' && ( PyUnicode_READ(kind, data, 1) == '}' || ( diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index dedbefe..12dba38 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -340,7 +340,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself, goto error; kind = PyUnicode_KIND(modified); out = PyUnicode_DATA(modified); - PyUnicode_WRITE(kind, PyUnicode_DATA(modified), 0, '\r'); + PyUnicode_WRITE(kind, out, 0, '\r'); memcpy(out + kind, PyUnicode_DATA(output), kind * output_len); Py_DECREF(output); output = modified; /* output remains ready */ @@ -367,7 +367,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself, /* Record which newlines are read and do newline translation if desired, all in one pass. */ { - void *in_str; + const void *in_str; Py_ssize_t len; int seennl = self->seennl; int only_lf = 0; @@ -447,7 +447,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself, else { void *translated; int kind = PyUnicode_KIND(output); - void *in_str = PyUnicode_DATA(output); + const void *in_str = PyUnicode_DATA(output); Py_ssize_t in, out; /* XXX: Previous in-place translation here is disabled as resizing is not possible anymore */ @@ -2085,7 +2085,7 @@ _PyIO_find_line_ending( else { /* Non-universal mode. */ Py_ssize_t readnl_len = PyUnicode_GET_LENGTH(readnl); - Py_UCS1 *nl = PyUnicode_1BYTE_DATA(readnl); + const Py_UCS1 *nl = PyUnicode_1BYTE_DATA(readnl); /* Assume that readnl is an ASCII character. */ assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND); if (readnl_len == 1) { @@ -2139,7 +2139,7 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit) chunked = 0; while (1) { - char *ptr; + const char *ptr; Py_ssize_t line_len; int kind; Py_ssize_t consumed = 0; diff --git a/Modules/_json.c b/Modules/_json.c index 3ab1cb3..1754416 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -159,8 +159,8 @@ ascii_escape_unicode(PyObject *pystr) Py_ssize_t output_size; Py_ssize_t chars; PyObject *rval; - void *input; - unsigned char *output; + const void *input; + Py_UCS1 *output; int kind; if (PyUnicode_READY(pystr) == -1) @@ -225,7 +225,7 @@ escape_unicode(PyObject *pystr) Py_ssize_t output_size; Py_ssize_t chars; PyObject *rval; - void *input; + const void *input; int kind; Py_UCS4 maxchar; @@ -678,7 +678,7 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss Returns a new PyObject (usually a dict, but object_hook can change that) */ - void *str; + const void *str; int kind; Py_ssize_t end_idx; PyObject *val = NULL; @@ -808,7 +808,7 @@ _parse_array_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssi Returns a new PyList */ - void *str; + const void *str; int kind; Py_ssize_t end_idx; PyObject *val = NULL; @@ -911,7 +911,7 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_ PyLong, or PyFloat. May return other types if parse_int or parse_float are set */ - void *str; + const void *str; int kind; Py_ssize_t end_idx; Py_ssize_t idx = start; @@ -1028,7 +1028,7 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_ Returns a new PyObject representation of the term. */ PyObject *res; - void *str; + const void *str; int kind; Py_ssize_t length; diff --git a/Modules/_operator.c b/Modules/_operator.c index 007c21b..19026b6 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -1170,7 +1170,7 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) for (idx = 0; idx < nattrs; ++idx) { PyObject *item = PyTuple_GET_ITEM(args, idx); Py_ssize_t item_len; - void *data; + const void *data; unsigned int kind; int dot_count; diff --git a/Modules/_pickle.c b/Modules/_pickle.c index c3385ad..4b46c1f 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -2581,7 +2581,7 @@ raw_unicode_escape(PyObject *obj) { char *p; Py_ssize_t i, size; - void *data; + const void *data; unsigned int kind; _PyBytesWriter writer; diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 697295d..92bdfe3 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1644,7 +1644,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) const char *uppercase_name_str; int rc; unsigned int kind; - void *data; + const void *data; if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { goto finally; diff --git a/Modules/_sre.c b/Modules/_sre.c index bee2e12..836d796 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -351,7 +351,7 @@ state_reset(SRE_STATE* state) data_stack_dealloc(state); } -static void* +static const void* getstring(PyObject* string, Py_ssize_t* p_length, int* p_isbytes, int* p_charsize, Py_buffer *view) @@ -398,11 +398,11 @@ state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string, Py_ssize_t length; int isbytes, charsize; - void* ptr; + const void* ptr; memset(state, 0, sizeof(SRE_STATE)); - state->mark = PyMem_New(void *, pattern->groups * 2); + state->mark = PyMem_New(const void *, pattern->groups * 2); if (!state->mark) { PyErr_NoMemory(); goto err; @@ -891,7 +891,7 @@ _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string, Py_ssize_t status; Py_ssize_t n; Py_ssize_t i; - void* last; + const void* last; assert(self->codesize != 0); @@ -984,7 +984,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string, PyObject* item; PyObject* filter; PyObject* match; - void* ptr; + const void* ptr; Py_ssize_t status; Py_ssize_t n; Py_ssize_t i, b, e; @@ -1895,7 +1895,7 @@ match_getslice_by_index(MatchObject* self, Py_ssize_t index, PyObject* def) int isbytes, charsize; Py_buffer view; PyObject *result; - void* ptr; + const void* ptr; Py_ssize_t i, j; assert(0 <= index && index < self->groups); diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index 8f6f880..e41755b 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -72,7 +72,7 @@ static const struct dbcs_map *mapping_list; #define ENCODER(encoding) \ static Py_ssize_t encoding##_encode( \ MultibyteCodec_State *state, const void *config, \ - int kind, void *data, \ + int kind, const void *data, \ Py_ssize_t *inpos, Py_ssize_t inlen, \ unsigned char **outbuf, Py_ssize_t outleft, int flags) #define ENCODER_RESET(encoding) \ diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index a09c75d..9f9fbeb 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -228,7 +228,7 @@ multibytecodec_encerror(MultibyteCodec *codec, Py_ssize_t r; Py_ssize_t inpos; int kind; - void *data; + const void *data; replchar = PyUnicode_FromOrdinal('?'); if (replchar == NULL) @@ -457,7 +457,7 @@ multibytecodec_encode(MultibyteCodec *codec, Py_ssize_t finalsize, r = 0; Py_ssize_t datalen; int kind; - void *data; + const void *data; if (PyUnicode_READY(text) < 0) return NULL; diff --git a/Modules/cjkcodecs/multibytecodec.h b/Modules/cjkcodecs/multibytecodec.h index 4d2b355..5946821 100644 --- a/Modules/cjkcodecs/multibytecodec.h +++ b/Modules/cjkcodecs/multibytecodec.h @@ -30,7 +30,7 @@ typedef struct { typedef int (*mbcodec_init)(const void *config); typedef Py_ssize_t (*mbencode_func)(MultibyteCodec_State *state, const void *config, - int kind, void *data, + int kind, const void *data, Py_ssize_t *inpos, Py_ssize_t inlen, unsigned char **outbuf, Py_ssize_t outleft, int flags); diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index a7f8b50..d930e3e 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1060,7 +1060,7 @@ PyUnknownEncodingHandler(void *encodingHandlerData, static unsigned char template_buffer[256] = {0}; PyObject* u; int i; - void *data; + const void *data; unsigned int kind; if (PyErr_Occurred()) diff --git a/Modules/sre.h b/Modules/sre.h index a728488..9b0d8b1 100644 --- a/Modules/sre.h +++ b/Modules/sre.h @@ -54,17 +54,17 @@ typedef struct { typedef struct SRE_REPEAT_T { Py_ssize_t count; - SRE_CODE* pattern; /* points to REPEAT operator arguments */ - void* last_ptr; /* helper to check for infinite loops */ + const SRE_CODE* pattern; /* points to REPEAT operator arguments */ + const void* last_ptr; /* helper to check for infinite loops */ struct SRE_REPEAT_T *prev; /* points to previous repeat context */ } SRE_REPEAT; typedef struct { /* string pointers */ - void* ptr; /* current position (also end of current slice) */ - void* beginning; /* start of original string */ - void* start; /* start of current slice */ - void* end; /* end of original string */ + const void* ptr; /* current position (also end of current slice) */ + const void* beginning; /* start of original string */ + const void* start; /* start of current slice */ + const void* end; /* end of original string */ /* attributes for the match object */ PyObject* string; Py_buffer buffer; @@ -74,7 +74,7 @@ typedef struct { /* registers */ Py_ssize_t lastindex; Py_ssize_t lastmark; - void** mark; + const void** mark; int match_all; int must_advance; /* dynamically allocated stuff */ diff --git a/Modules/sre_lib.h b/Modules/sre_lib.h index 437ab43..9cc7863 100644 --- a/Modules/sre_lib.h +++ b/Modules/sre_lib.h @@ -13,7 +13,7 @@ /* This file is included three times, with different character settings */ LOCAL(int) -SRE(at)(SRE_STATE* state, SRE_CHAR* ptr, SRE_CODE at) +SRE(at)(SRE_STATE* state, const SRE_CHAR* ptr, SRE_CODE at) { /* check if pointer is at given position */ @@ -101,7 +101,7 @@ SRE(at)(SRE_STATE* state, SRE_CHAR* ptr, SRE_CODE at) } LOCAL(int) -SRE(charset)(SRE_STATE* state, SRE_CODE* set, SRE_CODE ch) +SRE(charset)(SRE_STATE* state, const SRE_CODE* set, SRE_CODE ch) { /* check if character is a member of the given set */ @@ -188,7 +188,7 @@ SRE(charset)(SRE_STATE* state, SRE_CODE* set, SRE_CODE ch) } LOCAL(int) -SRE(charset_loc_ignore)(SRE_STATE* state, SRE_CODE* set, SRE_CODE ch) +SRE(charset_loc_ignore)(SRE_STATE* state, const SRE_CODE* set, SRE_CODE ch) { SRE_CODE lo, up; lo = sre_lower_locale(ch); @@ -199,15 +199,15 @@ SRE(charset_loc_ignore)(SRE_STATE* state, SRE_CODE* set, SRE_CODE ch) return up != lo && SRE(charset)(state, set, up); } -LOCAL(Py_ssize_t) SRE(match)(SRE_STATE* state, SRE_CODE* pattern, int toplevel); +LOCAL(Py_ssize_t) SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel); LOCAL(Py_ssize_t) -SRE(count)(SRE_STATE* state, SRE_CODE* pattern, Py_ssize_t maxcount) +SRE(count)(SRE_STATE* state, const SRE_CODE* pattern, Py_ssize_t maxcount) { SRE_CODE chr; SRE_CHAR c; - SRE_CHAR* ptr = (SRE_CHAR *)state->ptr; - SRE_CHAR* end = (SRE_CHAR *)state->end; + const SRE_CHAR* ptr = (const SRE_CHAR *)state->ptr; + const SRE_CHAR* end = (const SRE_CHAR *)state->end; Py_ssize_t i; /* adjust end */ @@ -335,14 +335,14 @@ SRE(count)(SRE_STATE* state, SRE_CODE* pattern, Py_ssize_t maxcount) #if 0 /* not used in this release */ LOCAL(int) -SRE(info)(SRE_STATE* state, SRE_CODE* pattern) +SRE(info)(SRE_STATE* state, const SRE_CODE* pattern) { /* check if an SRE_OP_INFO block matches at the current position. returns the number of SRE_CODE objects to skip if successful, 0 if no match */ - SRE_CHAR* end = (SRE_CHAR*) state->end; - SRE_CHAR* ptr = (SRE_CHAR*) state->ptr; + const SRE_CHAR* end = (const SRE_CHAR*) state->end; + const SRE_CHAR* ptr = (const SRE_CHAR*) state->ptr; Py_ssize_t i; /* check minimal length */ @@ -531,8 +531,8 @@ do { \ typedef struct { Py_ssize_t last_ctx_pos; Py_ssize_t jump; - SRE_CHAR* ptr; - SRE_CODE* pattern; + const SRE_CHAR* ptr; + const SRE_CODE* pattern; Py_ssize_t count; Py_ssize_t lastmark; Py_ssize_t lastindex; @@ -546,9 +546,9 @@ typedef struct { /* check if string matches the given pattern. returns <0 for error, 0 for failure, and 1 for success */ LOCAL(Py_ssize_t) -SRE(match)(SRE_STATE* state, SRE_CODE* pattern, int toplevel) +SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel) { - SRE_CHAR* end = (SRE_CHAR *)state->end; + const SRE_CHAR* end = (const SRE_CHAR *)state->end; Py_ssize_t alloc_pos, ctx_pos = -1; Py_ssize_t i, ret = 0; Py_ssize_t jump; diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 1a9e1c0..569e785 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -496,7 +496,7 @@ nfd_nfkd(PyObject *self, PyObject *input, int k) Py_UCS4 *output; Py_ssize_t i, o, osize; int kind; - void *data; + const void *data; /* Longest decomposition in Unicode 3.2: U+FDFA */ Py_UCS4 stack[20]; Py_ssize_t space, isize; @@ -643,7 +643,7 @@ nfc_nfkc(PyObject *self, PyObject *input, int k) { PyObject *result; int kind; - void *data; + const void *data; Py_UCS4 *output; Py_ssize_t i, i1, o, len; int f,l,index,index1,comb; @@ -804,7 +804,7 @@ is_normalized_quickcheck(PyObject *self, PyObject *input, Py_ssize_t i, len; int kind; - void *data; + const void *data; unsigned char prev_combining = 0; /* The two quickcheck bits at this shift have type QuickcheckResult. */ |