mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Added the const qualifier to char* variables that refer to readonly internal
UTF-8 represenatation of Unicode objects.
This commit is contained in:
parent
a98c4a984b
commit
85b0f5beb1
29 changed files with 60 additions and 61 deletions
|
@ -1893,7 +1893,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
|
|||
char *s = NULL;
|
||||
PyObject *stdin_encoding = NULL, *stdin_errors = NULL;
|
||||
PyObject *stdout_encoding = NULL, *stdout_errors = NULL;
|
||||
char *stdin_encoding_str, *stdin_errors_str;
|
||||
const char *stdin_encoding_str, *stdin_errors_str;
|
||||
PyObject *result;
|
||||
size_t len;
|
||||
|
||||
|
@ -1914,7 +1914,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
|
|||
Py_DECREF(tmp);
|
||||
if (prompt != NULL) {
|
||||
/* We have a prompt, encode it as stdout would */
|
||||
char *stdout_encoding_str, *stdout_errors_str;
|
||||
const char *stdout_encoding_str, *stdout_errors_str;
|
||||
PyObject *stringpo;
|
||||
stdout_encoding = _PyObject_GetAttrId(fout, &PyId_encoding);
|
||||
stdout_errors = _PyObject_GetAttrId(fout, &PyId_errors);
|
||||
|
|
|
@ -5440,8 +5440,8 @@ _PyEval_RequestCodeExtraIndex(freefunc free)
|
|||
static void
|
||||
dtrace_function_entry(PyFrameObject *f)
|
||||
{
|
||||
char* filename;
|
||||
char* funcname;
|
||||
const char *filename;
|
||||
const char *funcname;
|
||||
int lineno;
|
||||
|
||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
||||
|
@ -5454,8 +5454,8 @@ dtrace_function_entry(PyFrameObject *f)
|
|||
static void
|
||||
dtrace_function_return(PyFrameObject *f)
|
||||
{
|
||||
char* filename;
|
||||
char* funcname;
|
||||
const char *filename;
|
||||
const char *funcname;
|
||||
int lineno;
|
||||
|
||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
||||
|
@ -5471,7 +5471,7 @@ maybe_dtrace_line(PyFrameObject *frame,
|
|||
int *instr_lb, int *instr_ub, int *instr_prev)
|
||||
{
|
||||
int line = frame->f_lineno;
|
||||
char *co_filename, *co_name;
|
||||
const char *co_filename, *co_name;
|
||||
|
||||
/* If the last instruction executed isn't in the current
|
||||
instruction window, reset the window.
|
||||
|
|
|
@ -1131,7 +1131,7 @@ PyCodec_SurrogatePassErrors(PyObject *exc)
|
|||
PyObject *restuple;
|
||||
PyObject *object;
|
||||
PyObject *encode;
|
||||
char *encoding;
|
||||
const char *encoding;
|
||||
int code;
|
||||
int bytelength;
|
||||
Py_ssize_t i;
|
||||
|
|
|
@ -4039,7 +4039,7 @@ compiler_visit_keyword(struct compiler *c, keyword_ty k)
|
|||
static int
|
||||
expr_constant(struct compiler *c, expr_ty e)
|
||||
{
|
||||
char *id;
|
||||
const char *id;
|
||||
switch (e->kind) {
|
||||
case Ellipsis_kind:
|
||||
return 1;
|
||||
|
|
|
@ -74,7 +74,7 @@ static const char *converttuple(PyObject *, const char **, va_list *, int,
|
|||
int *, char *, size_t, int, freelist_t *);
|
||||
static const char *convertsimple(PyObject *, const char **, va_list *, int,
|
||||
char *, size_t, freelist_t *);
|
||||
static Py_ssize_t convertbuffer(PyObject *, void **p, const char **);
|
||||
static Py_ssize_t convertbuffer(PyObject *, const void **p, const char **);
|
||||
static int getbuffer(PyObject *, Py_buffer *, const char**);
|
||||
|
||||
static int vgetargskeywords(PyObject *, PyObject *,
|
||||
|
@ -625,7 +625,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
|
||||
const char *format = *p_format;
|
||||
char c = *format++;
|
||||
char *sarg;
|
||||
const char *sarg;
|
||||
|
||||
switch (c) {
|
||||
|
||||
|
@ -897,7 +897,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
}
|
||||
break;
|
||||
}
|
||||
count = convertbuffer(arg, p, &buf);
|
||||
count = convertbuffer(arg, (const void **)p, &buf);
|
||||
if (count < 0)
|
||||
return converterr(buf, arg, msgbuf, bufsize);
|
||||
if (*format == '#') {
|
||||
|
@ -928,7 +928,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
if (sarg == NULL)
|
||||
return converterr(CONV_UNICODE,
|
||||
arg, msgbuf, bufsize);
|
||||
PyBuffer_FillInfo(p, arg, sarg, len, 1, 0);
|
||||
PyBuffer_FillInfo(p, arg, (void *)sarg, len, 1, 0);
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
const char *buf;
|
||||
|
@ -943,7 +943,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
format++;
|
||||
} else if (*format == '#') { /* a string or read-only bytes-like object */
|
||||
/* "s#" or "z#" */
|
||||
void **p = (void **)va_arg(*p_va, char **);
|
||||
const void **p = (const void **)va_arg(*p_va, const char **);
|
||||
FETCH_SIZE;
|
||||
|
||||
if (c == 'z' && arg == Py_None) {
|
||||
|
@ -970,7 +970,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
format++;
|
||||
} else {
|
||||
/* "s" or "z" */
|
||||
char **p = va_arg(*p_va, char **);
|
||||
const char **p = va_arg(*p_va, const char **);
|
||||
Py_ssize_t len;
|
||||
sarg = NULL;
|
||||
|
||||
|
@ -1300,7 +1300,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
}
|
||||
|
||||
static Py_ssize_t
|
||||
convertbuffer(PyObject *arg, void **p, const char **errmsg)
|
||||
convertbuffer(PyObject *arg, const void **p, const char **errmsg)
|
||||
{
|
||||
PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer;
|
||||
Py_ssize_t count;
|
||||
|
|
|
@ -1035,7 +1035,7 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
|
|||
{
|
||||
struct _inittab *p;
|
||||
PyObject *name;
|
||||
char *namestr;
|
||||
const char *namestr;
|
||||
PyObject *mod;
|
||||
|
||||
name = PyObject_GetAttrString(spec, "name");
|
||||
|
|
|
@ -193,7 +193,8 @@ add_flag(int flag, const char *envs)
|
|||
static char*
|
||||
get_codec_name(const char *encoding)
|
||||
{
|
||||
char *name_utf8, *name_str;
|
||||
const char *name_utf8;
|
||||
char *name_str;
|
||||
PyObject *codec, *name = NULL;
|
||||
|
||||
codec = _PyCodec_Lookup(encoding);
|
||||
|
@ -1284,8 +1285,7 @@ initstdio(void)
|
|||
when import.c tries to write to stderr in verbose mode. */
|
||||
encoding_attr = PyObject_GetAttrString(std, "encoding");
|
||||
if (encoding_attr != NULL) {
|
||||
const char * std_encoding;
|
||||
std_encoding = PyUnicode_AsUTF8(encoding_attr);
|
||||
const char *std_encoding = PyUnicode_AsUTF8(encoding_attr);
|
||||
if (std_encoding != NULL) {
|
||||
PyObject *codec_info = _PyCodec_Lookup(std_encoding);
|
||||
Py_XDECREF(codec_info);
|
||||
|
|
|
@ -154,7 +154,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags)
|
|||
PyObject *m, *d, *v, *w, *oenc = NULL, *mod_name;
|
||||
mod_ty mod;
|
||||
PyArena *arena;
|
||||
char *ps1 = "", *ps2 = "", *enc = NULL;
|
||||
const char *ps1 = "", *ps2 = "", *enc = NULL;
|
||||
int errcode = 0;
|
||||
_Py_IDENTIFIER(encoding);
|
||||
_Py_IDENTIFIER(__main__);
|
||||
|
@ -511,8 +511,8 @@ PyErr_Print(void)
|
|||
static void
|
||||
print_error_text(PyObject *f, int offset, PyObject *text_obj)
|
||||
{
|
||||
char *text;
|
||||
char *nl;
|
||||
const char *text;
|
||||
const char *nl;
|
||||
|
||||
text = PyUnicode_AsUTF8(text_obj);
|
||||
if (text == NULL)
|
||||
|
|
|
@ -249,7 +249,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
|
|||
Py_XDECREF(oldv);
|
||||
break;
|
||||
case T_CHAR: {
|
||||
char *string;
|
||||
const char *string;
|
||||
Py_ssize_t len;
|
||||
|
||||
string = PyUnicode_AsUTF8AndSize(v, &len);
|
||||
|
|
|
@ -108,7 +108,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o)
|
|||
{
|
||||
PyObject *stdout_encoding = NULL;
|
||||
PyObject *encoded, *escaped_str, *repr_str, *buffer, *result;
|
||||
char *stdout_encoding_str;
|
||||
const char *stdout_encoding_str;
|
||||
int ret;
|
||||
|
||||
stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding);
|
||||
|
@ -2404,7 +2404,7 @@ sys_format(_Py_Identifier *key, FILE *fp, const char *format, va_list va)
|
|||
{
|
||||
PyObject *file, *message;
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
char *utf8;
|
||||
const char *utf8;
|
||||
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
file = _PySys_GetObjectId(key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue