mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -1829,7 +1829,7 @@ static PyCArgObject *
|
|||
PyCSimpleType_paramfunc(CDataObject *self)
|
||||
{
|
||||
StgDictObject *dict;
|
||||
char *fmt;
|
||||
const char *fmt;
|
||||
PyCArgObject *parg;
|
||||
struct fielddesc *fd;
|
||||
|
||||
|
@ -2039,7 +2039,7 @@ static PyObject *
|
|||
PyCSimpleType_from_param(PyObject *type, PyObject *value)
|
||||
{
|
||||
StgDictObject *dict;
|
||||
char *fmt;
|
||||
const char *fmt;
|
||||
PyCArgObject *parg;
|
||||
struct fielddesc *fd;
|
||||
PyObject *as_parameter;
|
||||
|
|
|
@ -488,8 +488,8 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
|
|||
bitsize = 0;
|
||||
|
||||
if (isStruct && !isPacked) {
|
||||
char *fieldfmt = dict->format ? dict->format : "B";
|
||||
char *fieldname = PyUnicode_AsUTF8(name);
|
||||
const char *fieldfmt = dict->format ? dict->format : "B";
|
||||
const char *fieldname = PyUnicode_AsUTF8(name);
|
||||
char *ptr;
|
||||
Py_ssize_t len;
|
||||
char *buf;
|
||||
|
|
|
@ -3613,7 +3613,7 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
|
|||
|
||||
for (i = 0; i < PySequence_Size(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)) {
|
||||
event_name = PyUnicode_AsUTF8(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 "
|
||||
"shutdown, possibly due to daemon threads",
|
||||
(PyObject *) self);
|
||||
char *msg = PyUnicode_AsUTF8(msgobj);
|
||||
const char *msg = PyUnicode_AsUTF8(msgobj);
|
||||
Py_FatalError(msg);
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -693,7 +693,7 @@ _io_StringIO___init___impl(stringio *self, PyObject *value,
|
|||
PyObject *newline_obj)
|
||||
/*[clinic end generated code: output=a421ea023b22ef4e input=cee2d9181b2577a3]*/
|
||||
{
|
||||
char *newline = "\n";
|
||||
const char *newline = "\n";
|
||||
Py_ssize_t value_len;
|
||||
|
||||
/* Parse the newline argument. We only want to allow unicode objects or
|
||||
|
|
|
@ -1941,7 +1941,7 @@ save_long(PicklerObject *self, PyObject *obj)
|
|||
goto error;
|
||||
}
|
||||
else {
|
||||
char *string;
|
||||
const char *string;
|
||||
|
||||
/* proto < 2: write the repr and newline. This is quadratic-time (in
|
||||
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;
|
||||
Py_ssize_t size;
|
||||
char *data;
|
||||
const char *data;
|
||||
int r;
|
||||
|
||||
if (PyUnicode_READY(obj))
|
||||
|
|
|
@ -1489,7 +1489,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
|
|||
PyObject* retval;
|
||||
Py_ssize_t i, len;
|
||||
_Py_IDENTIFIER(upper);
|
||||
char *uppercase_name_str;
|
||||
const char *uppercase_name_str;
|
||||
int rc;
|
||||
unsigned int kind;
|
||||
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)
|
||||
{
|
||||
Py_ssize_t _idx;
|
||||
char* key;
|
||||
const char *key;
|
||||
Py_ssize_t nitems, i;
|
||||
char* compare_key;
|
||||
const char *compare_key;
|
||||
|
||||
char* p1;
|
||||
char* p2;
|
||||
const char *p1;
|
||||
const char *p2;
|
||||
|
||||
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 rc = SQLITE_OK;
|
||||
char* string;
|
||||
const char *string;
|
||||
Py_ssize_t buflen;
|
||||
parameter_type paramtype;
|
||||
|
||||
|
|
|
@ -536,7 +536,7 @@ SplitObj(PyObject *arg)
|
|||
else if (PyUnicode_Check(arg)) {
|
||||
int argc;
|
||||
const char **argv;
|
||||
char *list = PyUnicode_AsUTF8(arg);
|
||||
const char *list = PyUnicode_AsUTF8(arg);
|
||||
|
||||
if (list == NULL ||
|
||||
Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
|
||||
|
@ -993,7 +993,7 @@ asBignumObj(PyObject *value)
|
|||
Tcl_Obj *result;
|
||||
int neg;
|
||||
PyObject *hexstr;
|
||||
char *hexchars;
|
||||
const char *hexchars;
|
||||
mp_int bigValue;
|
||||
|
||||
neg = Py_SIZE(value) < 0;
|
||||
|
@ -1723,7 +1723,7 @@ class varname_converter(CConverter):
|
|||
static int
|
||||
varname_converter(PyObject *in, void *_out)
|
||||
{
|
||||
char *s;
|
||||
const char *s;
|
||||
const char **out = (const char**)_out;
|
||||
if (PyBytes_Check(in)) {
|
||||
if (PyBytes_GET_SIZE(in) > INT_MAX) {
|
||||
|
|
|
@ -5982,7 +5982,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
|
|||
PyObject *hobj = NULL;
|
||||
PyObject *pobj = (PyObject *)NULL;
|
||||
char pbuf[30];
|
||||
char *hptr, *pptr;
|
||||
const char *hptr, *pptr;
|
||||
int family, socktype, protocol, flags;
|
||||
int error;
|
||||
PyObject *all = (PyObject *)NULL;
|
||||
|
|
|
@ -116,7 +116,7 @@ syslog_openlog(PyObject * self, PyObject * args, PyObject *kwds)
|
|||
long facility = LOG_USER;
|
||||
PyObject *new_S_ident_o = NULL;
|
||||
static char *keywords[] = {"ident", "logoption", "facility", 0};
|
||||
char *ident = NULL;
|
||||
const char *ident = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds,
|
||||
"|Ull:openlog", keywords, &new_S_ident_o, &logopt, &facility))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue