summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-11-20 08:16:47 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-11-20 08:16:47 (GMT)
commit85b0f5beb182cca8b1607accce2caab87ee29835 (patch)
tree0e55ae3180c2836152ceb4f9689fc7ed1ccb71c5 /Objects
parenta98c4a984b34f887076f4171b1e3303e164cbddf (diff)
downloadcpython-85b0f5beb182cca8b1607accce2caab87ee29835.zip
cpython-85b0f5beb182cca8b1607accce2caab87ee29835.tar.gz
cpython-85b0f5beb182cca8b1607accce2caab87ee29835.tar.bz2
Added the const qualifier to char* variables that refer to readonly internal
UTF-8 represenatation of Unicode objects.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c8
-rw-r--r--Objects/floatobject.c6
-rw-r--r--Objects/longobject.c3
-rw-r--r--Objects/moduleobject.c4
-rw-r--r--Objects/setobject.c2
-rw-r--r--Objects/structseq.c2
-rw-r--r--Objects/typeobject.c4
7 files changed, 14 insertions, 15 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index f442418..32f8a89 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -367,7 +367,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
{
PyObject *unicode;
PyObject *bytes = NULL;
- char *str;
+ const char *str;
Py_ssize_t n;
int err;
@@ -389,10 +389,8 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
bytes = _PyUnicode_AsUTF8String(unicode, "backslashreplace");
if (bytes == NULL)
return NULL;
- if (PyBytes_AsStringAndSize(bytes, &str, &n) < 0) {
- Py_DECREF(bytes);
- return NULL;
- }
+ str = PyBytes_AS_STRING(bytes);
+ n = PyBytes_GET_SIZE(bytes);
}
n = _Py_write(self->fd, str, n);
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 80bf71e..17a55dd 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1225,7 +1225,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
PyObject *result;
double x;
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;
Py_ssize_t length, ndigits, fdigits, i;
@@ -1288,7 +1288,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
s++;
/* 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) {
s = coeff_end;
goto finished;
@@ -1619,7 +1619,7 @@ static float_format_type detected_double_format, detected_float_format;
static PyObject *
float_getformat(PyTypeObject *v, PyObject* arg)
{
- char* s;
+ const char *s;
float_format_type r;
if (!PyUnicode_Check(arg)) {
diff --git a/Objects/longobject.c b/Objects/longobject.c
index b0f6b8c..822ed16 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -2491,7 +2491,8 @@ PyObject *
PyLong_FromUnicodeObject(PyObject *u, int base)
{
PyObject *result, *asciidig;
- char *buffer, *end = NULL;
+ const char *buffer;
+ char *end = NULL;
Py_ssize_t buflen;
asciidig = _PyUnicode_TransformDecimalAndSpaceToASCII(u);
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 79be51a..701bcb1 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -231,7 +231,7 @@ PyModule_FromDefAndSpec2(struct PyModuleDef* def, PyObject *spec, int module_api
PyObject *nameobj;
PyObject *m = NULL;
int has_execution_slots = 0;
- char *name;
+ const char *name;
int ret;
PyModuleDef_Init(def);
@@ -512,7 +512,7 @@ const char *
PyModule_GetFilename(PyObject *m)
{
PyObject *fileobj;
- char *utf8;
+ const char *utf8;
fileobj = PyModule_GetFilenameObject(m);
if (fileobj == NULL)
return NULL;
diff --git a/Objects/setobject.c b/Objects/setobject.c
index fdb9d36..b7e0617 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -2398,7 +2398,7 @@ static PyObject *
test_c_api(PySetObject *so)
{
Py_ssize_t count;
- char *s;
+ const char *s;
Py_ssize_t i;
PyObject *elem=NULL, *dup=NULL, *t, *f, *dup2, *x=NULL;
PyObject *ob = (PyObject *)so;
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 5489aef..6f1782f 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -182,7 +182,7 @@ structseq_repr(PyStructSequence *obj)
for (i=0; i < VISIBLE_SIZE(obj); i++) {
PyObject *val, *repr;
- char *cname, *crepr;
+ const char *cname, *crepr;
cname = typ->tp_members[i].name;
if (cname == NULL) {
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 606e08e..af09271 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1624,7 +1624,7 @@ consistent method resolution\norder (MRO) for bases");
i = 0;
while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) {
PyObject *name = class_name(k);
- char *name_str;
+ const char *name_str;
if (name != NULL) {
name_str = PyUnicode_AsUTF8(name);
if (name_str == NULL)
@@ -2572,7 +2572,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
PyObject *doc = _PyDict_GetItemId(dict, &PyId___doc__);
if (doc != NULL && PyUnicode_Check(doc)) {
Py_ssize_t len;
- char *doc_str;
+ const char *doc_str;
char *tp_doc;
doc_str = PyUnicode_AsUTF8(doc);