mirror of https://github.com/python/cpython
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
|
@ -1829,7 +1829,7 @@ static PyCArgObject *
|
||||||
PyCSimpleType_paramfunc(CDataObject *self)
|
PyCSimpleType_paramfunc(CDataObject *self)
|
||||||
{
|
{
|
||||||
StgDictObject *dict;
|
StgDictObject *dict;
|
||||||
char *fmt;
|
const char *fmt;
|
||||||
PyCArgObject *parg;
|
PyCArgObject *parg;
|
||||||
struct fielddesc *fd;
|
struct fielddesc *fd;
|
||||||
|
|
||||||
|
@ -2039,7 +2039,7 @@ static PyObject *
|
||||||
PyCSimpleType_from_param(PyObject *type, PyObject *value)
|
PyCSimpleType_from_param(PyObject *type, PyObject *value)
|
||||||
{
|
{
|
||||||
StgDictObject *dict;
|
StgDictObject *dict;
|
||||||
char *fmt;
|
const char *fmt;
|
||||||
PyCArgObject *parg;
|
PyCArgObject *parg;
|
||||||
struct fielddesc *fd;
|
struct fielddesc *fd;
|
||||||
PyObject *as_parameter;
|
PyObject *as_parameter;
|
||||||
|
|
|
@ -488,8 +488,8 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
|
||||||
bitsize = 0;
|
bitsize = 0;
|
||||||
|
|
||||||
if (isStruct && !isPacked) {
|
if (isStruct && !isPacked) {
|
||||||
char *fieldfmt = dict->format ? dict->format : "B";
|
const char *fieldfmt = dict->format ? dict->format : "B";
|
||||||
char *fieldname = PyUnicode_AsUTF8(name);
|
const char *fieldname = PyUnicode_AsUTF8(name);
|
||||||
char *ptr;
|
char *ptr;
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
|
@ -3613,7 +3613,7 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
|
||||||
|
|
||||||
for (i = 0; i < PySequence_Size(events_seq); ++i) {
|
for (i = 0; i < PySequence_Size(events_seq); ++i) {
|
||||||
PyObject *event_name_obj = PySequence_Fast_GET_ITEM(events_seq, i);
|
PyObject *event_name_obj = PySequence_Fast_GET_ITEM(events_seq, i);
|
||||||
char *event_name = NULL;
|
const char *event_name = NULL;
|
||||||
if (PyUnicode_Check(event_name_obj)) {
|
if (PyUnicode_Check(event_name_obj)) {
|
||||||
event_name = PyUnicode_AsUTF8(event_name_obj);
|
event_name = PyUnicode_AsUTF8(event_name_obj);
|
||||||
} else if (PyBytes_Check(event_name_obj)) {
|
} else if (PyBytes_Check(event_name_obj)) {
|
||||||
|
|
|
@ -305,7 +305,7 @@ _enter_buffered_busy(buffered *self)
|
||||||
"could not acquire lock for %A at interpreter "
|
"could not acquire lock for %A at interpreter "
|
||||||
"shutdown, possibly due to daemon threads",
|
"shutdown, possibly due to daemon threads",
|
||||||
(PyObject *) self);
|
(PyObject *) self);
|
||||||
char *msg = PyUnicode_AsUTF8(msgobj);
|
const char *msg = PyUnicode_AsUTF8(msgobj);
|
||||||
Py_FatalError(msg);
|
Py_FatalError(msg);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -693,7 +693,7 @@ _io_StringIO___init___impl(stringio *self, PyObject *value,
|
||||||
PyObject *newline_obj)
|
PyObject *newline_obj)
|
||||||
/*[clinic end generated code: output=a421ea023b22ef4e input=cee2d9181b2577a3]*/
|
/*[clinic end generated code: output=a421ea023b22ef4e input=cee2d9181b2577a3]*/
|
||||||
{
|
{
|
||||||
char *newline = "\n";
|
const char *newline = "\n";
|
||||||
Py_ssize_t value_len;
|
Py_ssize_t value_len;
|
||||||
|
|
||||||
/* Parse the newline argument. We only want to allow unicode objects or
|
/* Parse the newline argument. We only want to allow unicode objects or
|
||||||
|
|
|
@ -1941,7 +1941,7 @@ save_long(PicklerObject *self, PyObject *obj)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *string;
|
const char *string;
|
||||||
|
|
||||||
/* proto < 2: write the repr and newline. This is quadratic-time (in
|
/* proto < 2: write the repr and newline. This is quadratic-time (in
|
||||||
the number of digits), in both directions. We add a trailing 'L'
|
the number of digits), in both directions. We add a trailing 'L'
|
||||||
|
@ -2218,7 +2218,7 @@ write_unicode_binary(PicklerObject *self, PyObject *obj)
|
||||||
{
|
{
|
||||||
PyObject *encoded = NULL;
|
PyObject *encoded = NULL;
|
||||||
Py_ssize_t size;
|
Py_ssize_t size;
|
||||||
char *data;
|
const char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (PyUnicode_READY(obj))
|
if (PyUnicode_READY(obj))
|
||||||
|
|
|
@ -1489,7 +1489,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
|
||||||
PyObject* retval;
|
PyObject* retval;
|
||||||
Py_ssize_t i, len;
|
Py_ssize_t i, len;
|
||||||
_Py_IDENTIFIER(upper);
|
_Py_IDENTIFIER(upper);
|
||||||
char *uppercase_name_str;
|
const char *uppercase_name_str;
|
||||||
int rc;
|
int rc;
|
||||||
unsigned int kind;
|
unsigned int kind;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
|
@ -79,12 +79,12 @@ PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx)
|
||||||
PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
|
PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
|
||||||
{
|
{
|
||||||
Py_ssize_t _idx;
|
Py_ssize_t _idx;
|
||||||
char* key;
|
const char *key;
|
||||||
Py_ssize_t nitems, i;
|
Py_ssize_t nitems, i;
|
||||||
char* compare_key;
|
const char *compare_key;
|
||||||
|
|
||||||
char* p1;
|
const char *p1;
|
||||||
char* p2;
|
const char *p2;
|
||||||
|
|
||||||
PyObject* item;
|
PyObject* item;
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
|
||||||
int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter)
|
int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter)
|
||||||
{
|
{
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
char* string;
|
const char *string;
|
||||||
Py_ssize_t buflen;
|
Py_ssize_t buflen;
|
||||||
parameter_type paramtype;
|
parameter_type paramtype;
|
||||||
|
|
||||||
|
|
|
@ -536,7 +536,7 @@ SplitObj(PyObject *arg)
|
||||||
else if (PyUnicode_Check(arg)) {
|
else if (PyUnicode_Check(arg)) {
|
||||||
int argc;
|
int argc;
|
||||||
const char **argv;
|
const char **argv;
|
||||||
char *list = PyUnicode_AsUTF8(arg);
|
const char *list = PyUnicode_AsUTF8(arg);
|
||||||
|
|
||||||
if (list == NULL ||
|
if (list == NULL ||
|
||||||
Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
|
Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
|
||||||
|
@ -993,7 +993,7 @@ asBignumObj(PyObject *value)
|
||||||
Tcl_Obj *result;
|
Tcl_Obj *result;
|
||||||
int neg;
|
int neg;
|
||||||
PyObject *hexstr;
|
PyObject *hexstr;
|
||||||
char *hexchars;
|
const char *hexchars;
|
||||||
mp_int bigValue;
|
mp_int bigValue;
|
||||||
|
|
||||||
neg = Py_SIZE(value) < 0;
|
neg = Py_SIZE(value) < 0;
|
||||||
|
@ -1723,7 +1723,7 @@ class varname_converter(CConverter):
|
||||||
static int
|
static int
|
||||||
varname_converter(PyObject *in, void *_out)
|
varname_converter(PyObject *in, void *_out)
|
||||||
{
|
{
|
||||||
char *s;
|
const char *s;
|
||||||
const char **out = (const char**)_out;
|
const char **out = (const char**)_out;
|
||||||
if (PyBytes_Check(in)) {
|
if (PyBytes_Check(in)) {
|
||||||
if (PyBytes_GET_SIZE(in) > INT_MAX) {
|
if (PyBytes_GET_SIZE(in) > INT_MAX) {
|
||||||
|
|
|
@ -5982,7 +5982,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
|
||||||
PyObject *hobj = NULL;
|
PyObject *hobj = NULL;
|
||||||
PyObject *pobj = (PyObject *)NULL;
|
PyObject *pobj = (PyObject *)NULL;
|
||||||
char pbuf[30];
|
char pbuf[30];
|
||||||
char *hptr, *pptr;
|
const char *hptr, *pptr;
|
||||||
int family, socktype, protocol, flags;
|
int family, socktype, protocol, flags;
|
||||||
int error;
|
int error;
|
||||||
PyObject *all = (PyObject *)NULL;
|
PyObject *all = (PyObject *)NULL;
|
||||||
|
|
|
@ -116,7 +116,7 @@ syslog_openlog(PyObject * self, PyObject * args, PyObject *kwds)
|
||||||
long facility = LOG_USER;
|
long facility = LOG_USER;
|
||||||
PyObject *new_S_ident_o = NULL;
|
PyObject *new_S_ident_o = NULL;
|
||||||
static char *keywords[] = {"ident", "logoption", "facility", 0};
|
static char *keywords[] = {"ident", "logoption", "facility", 0};
|
||||||
char *ident = NULL;
|
const char *ident = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds,
|
if (!PyArg_ParseTupleAndKeywords(args, kwds,
|
||||||
"|Ull:openlog", keywords, &new_S_ident_o, &logopt, &facility))
|
"|Ull:openlog", keywords, &new_S_ident_o, &logopt, &facility))
|
||||||
|
|
|
@ -367,7 +367,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *unicode;
|
PyObject *unicode;
|
||||||
PyObject *bytes = NULL;
|
PyObject *bytes = NULL;
|
||||||
char *str;
|
const char *str;
|
||||||
Py_ssize_t n;
|
Py_ssize_t n;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -389,10 +389,8 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
|
||||||
bytes = _PyUnicode_AsUTF8String(unicode, "backslashreplace");
|
bytes = _PyUnicode_AsUTF8String(unicode, "backslashreplace");
|
||||||
if (bytes == NULL)
|
if (bytes == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (PyBytes_AsStringAndSize(bytes, &str, &n) < 0) {
|
str = PyBytes_AS_STRING(bytes);
|
||||||
Py_DECREF(bytes);
|
n = PyBytes_GET_SIZE(bytes);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
n = _Py_write(self->fd, str, n);
|
n = _Py_write(self->fd, str, n);
|
||||||
|
|
|
@ -1225,7 +1225,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
double x;
|
double x;
|
||||||
long exp, top_exp, lsb, key_digit;
|
long exp, top_exp, lsb, key_digit;
|
||||||
char *s, *coeff_start, *s_store, *coeff_end, *exp_start, *s_end;
|
const char *s, *coeff_start, *s_store, *coeff_end, *exp_start, *s_end;
|
||||||
int half_eps, digit, round_up, negate=0;
|
int half_eps, digit, round_up, negate=0;
|
||||||
Py_ssize_t length, ndigits, fdigits, i;
|
Py_ssize_t length, ndigits, fdigits, i;
|
||||||
|
|
||||||
|
@ -1288,7 +1288,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
/* infinities and nans */
|
/* infinities and nans */
|
||||||
x = _Py_parse_inf_or_nan(s, &coeff_end);
|
x = _Py_parse_inf_or_nan(s, (char **)&coeff_end);
|
||||||
if (coeff_end != s) {
|
if (coeff_end != s) {
|
||||||
s = coeff_end;
|
s = coeff_end;
|
||||||
goto finished;
|
goto finished;
|
||||||
|
@ -1619,7 +1619,7 @@ static float_format_type detected_double_format, detected_float_format;
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_getformat(PyTypeObject *v, PyObject* arg)
|
float_getformat(PyTypeObject *v, PyObject* arg)
|
||||||
{
|
{
|
||||||
char* s;
|
const char *s;
|
||||||
float_format_type r;
|
float_format_type r;
|
||||||
|
|
||||||
if (!PyUnicode_Check(arg)) {
|
if (!PyUnicode_Check(arg)) {
|
||||||
|
|
|
@ -2491,7 +2491,8 @@ PyObject *
|
||||||
PyLong_FromUnicodeObject(PyObject *u, int base)
|
PyLong_FromUnicodeObject(PyObject *u, int base)
|
||||||
{
|
{
|
||||||
PyObject *result, *asciidig;
|
PyObject *result, *asciidig;
|
||||||
char *buffer, *end = NULL;
|
const char *buffer;
|
||||||
|
char *end = NULL;
|
||||||
Py_ssize_t buflen;
|
Py_ssize_t buflen;
|
||||||
|
|
||||||
asciidig = _PyUnicode_TransformDecimalAndSpaceToASCII(u);
|
asciidig = _PyUnicode_TransformDecimalAndSpaceToASCII(u);
|
||||||
|
|
|
@ -231,7 +231,7 @@ PyModule_FromDefAndSpec2(struct PyModuleDef* def, PyObject *spec, int module_api
|
||||||
PyObject *nameobj;
|
PyObject *nameobj;
|
||||||
PyObject *m = NULL;
|
PyObject *m = NULL;
|
||||||
int has_execution_slots = 0;
|
int has_execution_slots = 0;
|
||||||
char *name;
|
const char *name;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
PyModuleDef_Init(def);
|
PyModuleDef_Init(def);
|
||||||
|
@ -512,7 +512,7 @@ const char *
|
||||||
PyModule_GetFilename(PyObject *m)
|
PyModule_GetFilename(PyObject *m)
|
||||||
{
|
{
|
||||||
PyObject *fileobj;
|
PyObject *fileobj;
|
||||||
char *utf8;
|
const char *utf8;
|
||||||
fileobj = PyModule_GetFilenameObject(m);
|
fileobj = PyModule_GetFilenameObject(m);
|
||||||
if (fileobj == NULL)
|
if (fileobj == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -2398,7 +2398,7 @@ static PyObject *
|
||||||
test_c_api(PySetObject *so)
|
test_c_api(PySetObject *so)
|
||||||
{
|
{
|
||||||
Py_ssize_t count;
|
Py_ssize_t count;
|
||||||
char *s;
|
const char *s;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
PyObject *elem=NULL, *dup=NULL, *t, *f, *dup2, *x=NULL;
|
PyObject *elem=NULL, *dup=NULL, *t, *f, *dup2, *x=NULL;
|
||||||
PyObject *ob = (PyObject *)so;
|
PyObject *ob = (PyObject *)so;
|
||||||
|
|
|
@ -182,7 +182,7 @@ structseq_repr(PyStructSequence *obj)
|
||||||
|
|
||||||
for (i=0; i < VISIBLE_SIZE(obj); i++) {
|
for (i=0; i < VISIBLE_SIZE(obj); i++) {
|
||||||
PyObject *val, *repr;
|
PyObject *val, *repr;
|
||||||
char *cname, *crepr;
|
const char *cname, *crepr;
|
||||||
|
|
||||||
cname = typ->tp_members[i].name;
|
cname = typ->tp_members[i].name;
|
||||||
if (cname == NULL) {
|
if (cname == NULL) {
|
||||||
|
|
|
@ -1624,7 +1624,7 @@ consistent method resolution\norder (MRO) for bases");
|
||||||
i = 0;
|
i = 0;
|
||||||
while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) {
|
while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) {
|
||||||
PyObject *name = class_name(k);
|
PyObject *name = class_name(k);
|
||||||
char *name_str;
|
const char *name_str;
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
name_str = PyUnicode_AsUTF8(name);
|
name_str = PyUnicode_AsUTF8(name);
|
||||||
if (name_str == NULL)
|
if (name_str == NULL)
|
||||||
|
@ -2572,7 +2572,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
||||||
PyObject *doc = _PyDict_GetItemId(dict, &PyId___doc__);
|
PyObject *doc = _PyDict_GetItemId(dict, &PyId___doc__);
|
||||||
if (doc != NULL && PyUnicode_Check(doc)) {
|
if (doc != NULL && PyUnicode_Check(doc)) {
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
char *doc_str;
|
const char *doc_str;
|
||||||
char *tp_doc;
|
char *tp_doc;
|
||||||
|
|
||||||
doc_str = PyUnicode_AsUTF8(doc);
|
doc_str = PyUnicode_AsUTF8(doc);
|
||||||
|
|
|
@ -1893,7 +1893,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
PyObject *stdin_encoding = NULL, *stdin_errors = NULL;
|
PyObject *stdin_encoding = NULL, *stdin_errors = NULL;
|
||||||
PyObject *stdout_encoding = NULL, *stdout_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;
|
PyObject *result;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
@ -1914,7 +1914,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
if (prompt != NULL) {
|
if (prompt != NULL) {
|
||||||
/* We have a prompt, encode it as stdout would */
|
/* 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;
|
PyObject *stringpo;
|
||||||
stdout_encoding = _PyObject_GetAttrId(fout, &PyId_encoding);
|
stdout_encoding = _PyObject_GetAttrId(fout, &PyId_encoding);
|
||||||
stdout_errors = _PyObject_GetAttrId(fout, &PyId_errors);
|
stdout_errors = _PyObject_GetAttrId(fout, &PyId_errors);
|
||||||
|
|
|
@ -5440,8 +5440,8 @@ _PyEval_RequestCodeExtraIndex(freefunc free)
|
||||||
static void
|
static void
|
||||||
dtrace_function_entry(PyFrameObject *f)
|
dtrace_function_entry(PyFrameObject *f)
|
||||||
{
|
{
|
||||||
char* filename;
|
const char *filename;
|
||||||
char* funcname;
|
const char *funcname;
|
||||||
int lineno;
|
int lineno;
|
||||||
|
|
||||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
||||||
|
@ -5454,8 +5454,8 @@ dtrace_function_entry(PyFrameObject *f)
|
||||||
static void
|
static void
|
||||||
dtrace_function_return(PyFrameObject *f)
|
dtrace_function_return(PyFrameObject *f)
|
||||||
{
|
{
|
||||||
char* filename;
|
const char *filename;
|
||||||
char* funcname;
|
const char *funcname;
|
||||||
int lineno;
|
int lineno;
|
||||||
|
|
||||||
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
|
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 *instr_lb, int *instr_ub, int *instr_prev)
|
||||||
{
|
{
|
||||||
int line = frame->f_lineno;
|
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
|
/* If the last instruction executed isn't in the current
|
||||||
instruction window, reset the window.
|
instruction window, reset the window.
|
||||||
|
|
|
@ -1131,7 +1131,7 @@ PyCodec_SurrogatePassErrors(PyObject *exc)
|
||||||
PyObject *restuple;
|
PyObject *restuple;
|
||||||
PyObject *object;
|
PyObject *object;
|
||||||
PyObject *encode;
|
PyObject *encode;
|
||||||
char *encoding;
|
const char *encoding;
|
||||||
int code;
|
int code;
|
||||||
int bytelength;
|
int bytelength;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
|
|
@ -4039,7 +4039,7 @@ compiler_visit_keyword(struct compiler *c, keyword_ty k)
|
||||||
static int
|
static int
|
||||||
expr_constant(struct compiler *c, expr_ty e)
|
expr_constant(struct compiler *c, expr_ty e)
|
||||||
{
|
{
|
||||||
char *id;
|
const char *id;
|
||||||
switch (e->kind) {
|
switch (e->kind) {
|
||||||
case Ellipsis_kind:
|
case Ellipsis_kind:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -74,7 +74,7 @@ static const char *converttuple(PyObject *, const char **, va_list *, int,
|
||||||
int *, char *, size_t, int, freelist_t *);
|
int *, char *, size_t, int, freelist_t *);
|
||||||
static const char *convertsimple(PyObject *, const char **, va_list *, int,
|
static const char *convertsimple(PyObject *, const char **, va_list *, int,
|
||||||
char *, size_t, freelist_t *);
|
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 getbuffer(PyObject *, Py_buffer *, const char**);
|
||||||
|
|
||||||
static int vgetargskeywords(PyObject *, PyObject *,
|
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;
|
const char *format = *p_format;
|
||||||
char c = *format++;
|
char c = *format++;
|
||||||
char *sarg;
|
const char *sarg;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
|
||||||
|
@ -897,7 +897,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
count = convertbuffer(arg, p, &buf);
|
count = convertbuffer(arg, (const void **)p, &buf);
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return converterr(buf, arg, msgbuf, bufsize);
|
return converterr(buf, arg, msgbuf, bufsize);
|
||||||
if (*format == '#') {
|
if (*format == '#') {
|
||||||
|
@ -928,7 +928,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
if (sarg == NULL)
|
if (sarg == NULL)
|
||||||
return converterr(CONV_UNICODE,
|
return converterr(CONV_UNICODE,
|
||||||
arg, msgbuf, bufsize);
|
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 */
|
else { /* any bytes-like object */
|
||||||
const char *buf;
|
const char *buf;
|
||||||
|
@ -943,7 +943,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
format++;
|
format++;
|
||||||
} else if (*format == '#') { /* a string or read-only bytes-like object */
|
} else if (*format == '#') { /* a string or read-only bytes-like object */
|
||||||
/* "s#" or "z#" */
|
/* "s#" or "z#" */
|
||||||
void **p = (void **)va_arg(*p_va, char **);
|
const void **p = (const void **)va_arg(*p_va, const char **);
|
||||||
FETCH_SIZE;
|
FETCH_SIZE;
|
||||||
|
|
||||||
if (c == 'z' && arg == Py_None) {
|
if (c == 'z' && arg == Py_None) {
|
||||||
|
@ -970,7 +970,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
format++;
|
format++;
|
||||||
} else {
|
} else {
|
||||||
/* "s" or "z" */
|
/* "s" or "z" */
|
||||||
char **p = va_arg(*p_va, char **);
|
const char **p = va_arg(*p_va, const char **);
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
sarg = NULL;
|
sarg = NULL;
|
||||||
|
|
||||||
|
@ -1300,7 +1300,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Py_ssize_t
|
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;
|
PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer;
|
||||||
Py_ssize_t count;
|
Py_ssize_t count;
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
|
||||||
{
|
{
|
||||||
struct _inittab *p;
|
struct _inittab *p;
|
||||||
PyObject *name;
|
PyObject *name;
|
||||||
char *namestr;
|
const char *namestr;
|
||||||
PyObject *mod;
|
PyObject *mod;
|
||||||
|
|
||||||
name = PyObject_GetAttrString(spec, "name");
|
name = PyObject_GetAttrString(spec, "name");
|
||||||
|
|
|
@ -193,7 +193,8 @@ add_flag(int flag, const char *envs)
|
||||||
static char*
|
static char*
|
||||||
get_codec_name(const char *encoding)
|
get_codec_name(const char *encoding)
|
||||||
{
|
{
|
||||||
char *name_utf8, *name_str;
|
const char *name_utf8;
|
||||||
|
char *name_str;
|
||||||
PyObject *codec, *name = NULL;
|
PyObject *codec, *name = NULL;
|
||||||
|
|
||||||
codec = _PyCodec_Lookup(encoding);
|
codec = _PyCodec_Lookup(encoding);
|
||||||
|
@ -1284,8 +1285,7 @@ initstdio(void)
|
||||||
when import.c tries to write to stderr in verbose mode. */
|
when import.c tries to write to stderr in verbose mode. */
|
||||||
encoding_attr = PyObject_GetAttrString(std, "encoding");
|
encoding_attr = PyObject_GetAttrString(std, "encoding");
|
||||||
if (encoding_attr != NULL) {
|
if (encoding_attr != NULL) {
|
||||||
const char * std_encoding;
|
const char *std_encoding = PyUnicode_AsUTF8(encoding_attr);
|
||||||
std_encoding = PyUnicode_AsUTF8(encoding_attr);
|
|
||||||
if (std_encoding != NULL) {
|
if (std_encoding != NULL) {
|
||||||
PyObject *codec_info = _PyCodec_Lookup(std_encoding);
|
PyObject *codec_info = _PyCodec_Lookup(std_encoding);
|
||||||
Py_XDECREF(codec_info);
|
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;
|
PyObject *m, *d, *v, *w, *oenc = NULL, *mod_name;
|
||||||
mod_ty mod;
|
mod_ty mod;
|
||||||
PyArena *arena;
|
PyArena *arena;
|
||||||
char *ps1 = "", *ps2 = "", *enc = NULL;
|
const char *ps1 = "", *ps2 = "", *enc = NULL;
|
||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
_Py_IDENTIFIER(encoding);
|
_Py_IDENTIFIER(encoding);
|
||||||
_Py_IDENTIFIER(__main__);
|
_Py_IDENTIFIER(__main__);
|
||||||
|
@ -511,8 +511,8 @@ PyErr_Print(void)
|
||||||
static void
|
static void
|
||||||
print_error_text(PyObject *f, int offset, PyObject *text_obj)
|
print_error_text(PyObject *f, int offset, PyObject *text_obj)
|
||||||
{
|
{
|
||||||
char *text;
|
const char *text;
|
||||||
char *nl;
|
const char *nl;
|
||||||
|
|
||||||
text = PyUnicode_AsUTF8(text_obj);
|
text = PyUnicode_AsUTF8(text_obj);
|
||||||
if (text == NULL)
|
if (text == NULL)
|
||||||
|
|
|
@ -249,7 +249,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
|
||||||
Py_XDECREF(oldv);
|
Py_XDECREF(oldv);
|
||||||
break;
|
break;
|
||||||
case T_CHAR: {
|
case T_CHAR: {
|
||||||
char *string;
|
const char *string;
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
|
|
||||||
string = PyUnicode_AsUTF8AndSize(v, &len);
|
string = PyUnicode_AsUTF8AndSize(v, &len);
|
||||||
|
|
|
@ -108,7 +108,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o)
|
||||||
{
|
{
|
||||||
PyObject *stdout_encoding = NULL;
|
PyObject *stdout_encoding = NULL;
|
||||||
PyObject *encoded, *escaped_str, *repr_str, *buffer, *result;
|
PyObject *encoded, *escaped_str, *repr_str, *buffer, *result;
|
||||||
char *stdout_encoding_str;
|
const char *stdout_encoding_str;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
stdout_encoding = _PyObject_GetAttrId(outf, &PyId_encoding);
|
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 *file, *message;
|
||||||
PyObject *error_type, *error_value, *error_traceback;
|
PyObject *error_type, *error_value, *error_traceback;
|
||||||
char *utf8;
|
const char *utf8;
|
||||||
|
|
||||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||||
file = _PySys_GetObjectId(key);
|
file = _PySys_GetObjectId(key);
|
||||||
|
|
Loading…
Reference in New Issue