summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/c-api/dict.rst2
-rw-r--r--Doc/c-api/file.rst2
-rw-r--r--Doc/c-api/import.rst8
-rw-r--r--Doc/c-api/long.rst2
-rw-r--r--Doc/c-api/mapping.rst6
-rw-r--r--Doc/c-api/veryhigh.rst2
-rw-r--r--Doc/data/refcounts.dat18
-rw-r--r--Include/abstract.h19
-rw-r--r--Include/fileobject.h5
-rw-r--r--Include/grammar.h6
-rw-r--r--Include/import.h18
-rw-r--r--Include/longobject.h6
-rw-r--r--Include/marshal.h3
-rw-r--r--Include/parsetok.h15
-rw-r--r--Include/pyport.h6
-rw-r--r--Include/pythonrun.h4
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_sqlite/statement.c2
-rw-r--r--Modules/cjkcodecs/cjkcodecs.h2
-rw-r--r--Modules/readline.c4
-rw-r--r--Objects/abstract.c8
-rw-r--r--Objects/bytesobject.c2
-rw-r--r--Objects/exceptions.c8
-rw-r--r--Objects/fileobject.c4
-rw-r--r--Objects/longobject.c16
-rw-r--r--Objects/unicodeobject.c2
-rw-r--r--Parser/grammar.c6
-rw-r--r--Parser/myreadline.c6
-rw-r--r--Parser/parser.c4
-rw-r--r--Parser/parsetok.c15
-rw-r--r--Parser/pgenmain.c2
-rw-r--r--Parser/tokenizer.c7
-rw-r--r--Parser/tokenizer.h6
-rw-r--r--Python/ast.c14
-rw-r--r--Python/bltinmodule.c2
-rw-r--r--Python/codecs.c4
-rw-r--r--Python/import.c17
-rw-r--r--Python/marshal.c6
-rw-r--r--Python/mystrtoul.c24
39 files changed, 148 insertions, 137 deletions
diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst
index 1f599fe..5a9dca2 100644
--- a/Doc/c-api/dict.rst
+++ b/Doc/c-api/dict.rst
@@ -84,7 +84,7 @@ Dictionary Objects
on failure.
-.. c:function:: int PyDict_DelItemString(PyObject *p, char *key)
+.. c:function:: int PyDict_DelItemString(PyObject *p, const char *key)
Remove the entry in dictionary *p* which has a key specified by the string
*key*. Return ``0`` on success or ``-1`` on failure.
diff --git a/Doc/c-api/file.rst b/Doc/c-api/file.rst
index cc190c9..6f2ecee 100644
--- a/Doc/c-api/file.rst
+++ b/Doc/c-api/file.rst
@@ -17,7 +17,7 @@ error reporting in the interpreter; third-party code is advised to access
the :mod:`io` APIs instead.
-.. c:function:: PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding, char *errors, char *newline, int closefd)
+.. c:function:: PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd)
Create a Python file object from the file descriptor of an already
opened file *fd*. The arguments *name*, *encoding*, *errors* and *newline*
diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst
index 270152e..6cd2b8b 100644
--- a/Doc/c-api/import.rst
+++ b/Doc/c-api/import.rst
@@ -118,7 +118,7 @@ Importing Modules
encoded string instead of a Unicode object.
-.. c:function:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
+.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
.. index:: builtin: compile
@@ -145,7 +145,7 @@ Importing Modules
:c:func:`PyImport_ExecCodeModuleWithPathnames`.
-.. c:function:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
+.. c:function:: PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of
the module object is set to *pathname* if it is non-``NULL``.
@@ -162,7 +162,7 @@ Importing Modules
.. versionadded:: 3.3
-.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(char *name, PyObject *co, char *pathname, char *cpathname)
+.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)
Like :c:func:`PyImport_ExecCodeModuleObject`, but *name*, *pathname* and
*cpathname* are UTF-8 encoded strings. Attempts are also made to figure out
@@ -246,7 +246,7 @@ Importing Modules
.. versionadded:: 3.3
-.. c:function:: int PyImport_ImportFrozenModule(char *name)
+.. c:function:: int PyImport_ImportFrozenModule(const char *name)
Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a
UTF-8 encoded string instead of a Unicode object.
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index d5430fd..b348015 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -80,7 +80,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
*NULL* on failure.
-.. c:function:: PyObject* PyLong_FromString(char *str, char **pend, int base)
+.. c:function:: PyObject* PyLong_FromString(const char *str, char **pend, int base)
Return a new :c:type:`PyLongObject` based on the string value in *str*, which
is interpreted according to the radix in *base*. If *pend* is non-*NULL*,
diff --git a/Doc/c-api/mapping.rst b/Doc/c-api/mapping.rst
index 0ef2961..2803fd0 100644
--- a/Doc/c-api/mapping.rst
+++ b/Doc/c-api/mapping.rst
@@ -22,7 +22,7 @@ Mapping Protocol
expression ``len(o)``.
-.. c:function:: int PyMapping_DelItemString(PyObject *o, char *key)
+.. c:function:: int PyMapping_DelItemString(PyObject *o, const char *key)
Remove the mapping for object *key* from the object *o*. Return ``-1`` on
failure. This is equivalent to the Python statement ``del o[key]``.
@@ -67,13 +67,13 @@ Mapping Protocol
the Python expression ``list(o.items())``.
-.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
+.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, const char *key)
Return element of *o* corresponding to the object *key* or *NULL* on failure.
This is the equivalent of the Python expression ``o[key]``.
-.. c:function:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v)
+.. c:function:: int PyMapping_SetItemString(PyObject *o, const char *key, PyObject *v)
Map the object *key* to the value *v* in object *o*. Returns ``-1`` on failure.
This is the equivalent of the Python statement ``o[key] = v``.
diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst
index a129963..9f21b89 100644
--- a/Doc/c-api/veryhigh.rst
+++ b/Doc/c-api/veryhigh.rst
@@ -155,7 +155,7 @@ the same library that the Python runtime is using.
Python source code.
-.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *)
+.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *)
Can be set to point to a function with the prototype
``char *func(FILE *stdin, FILE *stdout, char *prompt)``,
diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat
index 83f23eb..814c3b0 100644
--- a/Doc/data/refcounts.dat
+++ b/Doc/data/refcounts.dat
@@ -508,13 +508,13 @@ PyImport_AddModule:const char*:name::
PyImport_Cleanup:void:::
PyImport_ExecCodeModule:PyObject*::+1:
-PyImport_ExecCodeModule:char*:name::
+PyImport_ExecCodeModule:const char*:name::
PyImport_ExecCodeModule:PyObject*:co:0:
PyImport_ExecCodeModuleEx:PyObject*::+1:
-PyImport_ExecCodeModuleEx:char*:name::
+PyImport_ExecCodeModuleEx:const char*:name::
PyImport_ExecCodeModuleEx:PyObject*:co:0:
-PyImport_ExecCodeModuleEx:char*:pathname::
+PyImport_ExecCodeModuleEx:const char*:pathname::
PyImport_GetMagicNumber:long:::
@@ -524,7 +524,7 @@ PyImport_Import:PyObject*::+1:
PyImport_Import:PyObject*:name:0:
PyImport_ImportFrozenModule:int:::
-PyImport_ImportFrozenModule:char*:::
+PyImport_ImportFrozenModule:const char*:::
PyImport_ImportModule:PyObject*::+1:
PyImport_ImportModule:const char*:name::
@@ -673,7 +673,7 @@ PyLong_FromUnsignedLongLong:PyObject*::+1:
PyLong_FromUnsignedLongLong:unsigned long long:v::
PyLong_FromString:PyObject*::+1:
-PyLong_FromString:char*:str::
+PyLong_FromString:const char*:str::
PyLong_FromString:char**:pend::
PyLong_FromString:int:base::
@@ -701,7 +701,7 @@ PyMapping_DelItemString:const char*:key::
PyMapping_GetItemString:PyObject*::+1:
PyMapping_GetItemString:PyObject*:o:0:
-PyMapping_GetItemString:char*:key::
+PyMapping_GetItemString:const char*:key::
PyMapping_HasKey:int:::
PyMapping_HasKey:PyObject*:o:0:
@@ -709,7 +709,7 @@ PyMapping_HasKey:PyObject*:key::
PyMapping_HasKeyString:int:::
PyMapping_HasKeyString:PyObject*:o:0:
-PyMapping_HasKeyString:char*:key::
+PyMapping_HasKeyString:const char*:key::
PyMapping_Items:PyObject*::+1:
PyMapping_Items:PyObject*:o:0:
@@ -722,7 +722,7 @@ PyMapping_Length:PyObject*:o:0:
PyMapping_SetItemString:int:::
PyMapping_SetItemString:PyObject*:o:0:
-PyMapping_SetItemString:char*:key::
+PyMapping_SetItemString:const char*:key::
PyMapping_SetItemString:PyObject*:v:+1:
PyMapping_Values:PyObject*::+1:
@@ -735,7 +735,7 @@ PyMarshal_ReadObjectFromFile:PyObject*::+1:
PyMarshal_ReadObjectFromFile:FILE*:file::
PyMarshal_ReadObjectFromString:PyObject*::+1:
-PyMarshal_ReadObjectFromString:char*:string::
+PyMarshal_ReadObjectFromString:const char*:string::
PyMarshal_ReadObjectFromString:int:len::
PyMarshal_WriteObjectToString:PyObject*::+1:
diff --git a/Include/abstract.h b/Include/abstract.h
index a1f0595..d258ad5 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -144,7 +144,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* Implemented elsewhere:
- int PyObject_HasAttrString(PyObject *o, char *attr_name);
+ int PyObject_HasAttrString(PyObject *o, const char *attr_name);
Returns 1 if o has the attribute attr_name, and 0 otherwise.
This is equivalent to the Python expression:
@@ -156,7 +156,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* Implemented elsewhere:
- PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name);
+ PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name);
Retrieve an attributed named attr_name form object o.
Returns the attribute value on success, or NULL on failure.
@@ -189,7 +189,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* Implemented elsewhere:
- int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v);
+ int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v);
Set the value of the attribute named attr_name, for object o,
to the value, v. Returns -1 on failure. This is
@@ -209,7 +209,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* implemented as a macro:
- int PyObject_DelAttrString(PyObject *o, char *attr_name);
+ int PyObject_DelAttrString(PyObject *o, const char *attr_name);
Delete attribute named attr_name, for object o. Returns
-1 on failure. This is the equivalent of the Python
@@ -434,7 +434,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
statement: o[key]=v.
*/
- PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key);
+ PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key);
/*
Remove the mapping for object, key, from the object *o.
@@ -1156,7 +1156,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
/* implemented as a macro:
- int PyMapping_DelItemString(PyObject *o, char *key);
+ int PyMapping_DelItemString(PyObject *o, const char *key);
Remove the mapping for object, key, from the object *o.
Returns -1 on failure. This is equivalent to
@@ -1174,7 +1174,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
*/
#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))
- PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key);
+ PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);
/*
On success, return 1 if the mapping object has the key, key,
@@ -1218,7 +1218,8 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
*/
- PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key);
+ PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o,
+ const char *key);
/*
Return element of o corresponding to the object, key, or NULL
@@ -1226,7 +1227,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
o[key].
*/
- PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key,
+ PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key,
PyObject *value);
/*
diff --git a/Include/fileobject.h b/Include/fileobject.h
index a99c94d..0939744 100644
--- a/Include/fileobject.h
+++ b/Include/fileobject.h
@@ -8,8 +8,9 @@ extern "C" {
#define PY_STDIOTEXTMODE "b"
-PyAPI_FUNC(PyObject *) PyFile_FromFd(int, char *, char *, int, char *, char *,
- char *, int);
+PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int,
+ const char *, const char *,
+ const char *, int);
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
diff --git a/Include/grammar.h b/Include/grammar.h
index 862f6a8..ba7d19d 100644
--- a/Include/grammar.h
+++ b/Include/grammar.h
@@ -69,13 +69,13 @@ typedef struct {
/* FUNCTIONS */
grammar *newgrammar(int start);
-dfa *adddfa(grammar *g, int type, char *name);
+dfa *adddfa(grammar *g, int type, const char *name);
int addstate(dfa *d);
void addarc(dfa *d, int from, int to, int lbl);
dfa *PyGrammar_FindDFA(grammar *g, int type);
-int addlabel(labellist *ll, int type, char *str);
-int findlabel(labellist *ll, int type, char *str);
+int addlabel(labellist *ll, int type, const char *str);
+int findlabel(labellist *ll, int type, const char *str);
const char *PyGrammar_LabelRepr(label *lb);
void translatelabels(grammar *g);
diff --git a/Include/import.h b/Include/import.h
index 90049e0..4a515d5b 100644
--- a/Include/import.h
+++ b/Include/import.h
@@ -13,19 +13,19 @@ PyMODINIT_FUNC PyInit_imp(void);
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
- char *name, /* UTF-8 encoded string */
+ const char *name, /* UTF-8 encoded string */
PyObject *co
);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
- char *name, /* UTF-8 encoded string */
+ const char *name, /* UTF-8 encoded string */
PyObject *co,
- char *pathname /* decoded from the filesystem encoding */
+ const char *pathname /* decoded from the filesystem encoding */
);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
- char *name, /* UTF-8 encoded string */
+ const char *name, /* UTF-8 encoded string */
PyObject *co,
- char *pathname, /* decoded from the filesystem encoding */
- char *cpathname /* decoded from the filesystem encoding */
+ const char *pathname, /* decoded from the filesystem encoding */
+ const char *cpathname /* decoded from the filesystem encoding */
);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
PyObject *name,
@@ -72,7 +72,7 @@ PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
PyObject *name
);
PyAPI_FUNC(int) PyImport_ImportFrozenModule(
- char *name /* UTF-8 encoded string */
+ const char *name /* UTF-8 encoded string */
);
#ifndef Py_LIMITED_API
@@ -92,12 +92,12 @@ PyAPI_FUNC(PyObject *)_PyImport_FindBuiltin(
PyAPI_FUNC(PyObject *)_PyImport_FindExtensionObject(PyObject *, PyObject *);
PyAPI_FUNC(int)_PyImport_FixupBuiltin(
PyObject *mod,
- char *name /* UTF-8 encoded string */
+ const char *name /* UTF-8 encoded string */
);
PyAPI_FUNC(int)_PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
struct _inittab {
- char *name; /* ASCII encoded string */
+ const char *name; /* ASCII encoded string */
PyObject* (*initfunc)(void);
};
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
diff --git a/Include/longobject.h b/Include/longobject.h
index e62d954..7c3f6d0 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -93,7 +93,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
#endif /* HAVE_LONG_LONG */
-PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
+PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
@@ -189,8 +189,8 @@ PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
/* These aren't really part of the int object, but they're handy. The
functions are in Python/mystrtoul.c.
*/
-PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int);
-PyAPI_FUNC(long) PyOS_strtol(char *, char **, int);
+PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
+PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
#ifdef __cplusplus
}
diff --git a/Include/marshal.h b/Include/marshal.h
index 77d9c5e..09d9337 100644
--- a/Include/marshal.h
+++ b/Include/marshal.h
@@ -19,7 +19,8 @@ PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
#endif
-PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
+PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
+ Py_ssize_t);
#ifdef __cplusplus
}
diff --git a/Include/parsetok.h b/Include/parsetok.h
index 68b59bc..2acb854 100644
--- a/Include/parsetok.h
+++ b/Include/parsetok.h
@@ -38,7 +38,8 @@ typedef struct {
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
perrdetail *);
PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
- char *, char *, perrdetail *);
+ const char *, const char *,
+ perrdetail *);
PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
perrdetail *, int);
@@ -48,8 +49,8 @@ PyAPI_FUNC(node *) PyParser_ParseFileFlags(
const char *enc,
grammar *g,
int start,
- char *ps1,
- char *ps2,
+ const char *ps1,
+ const char *ps2,
perrdetail *err_ret,
int flags);
PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
@@ -58,8 +59,8 @@ PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
const char *enc,
grammar *g,
int start,
- char *ps1,
- char *ps2,
+ const char *ps1,
+ const char *ps2,
perrdetail *err_ret,
int *flags);
PyAPI_FUNC(node *) PyParser_ParseFileObject(
@@ -68,8 +69,8 @@ PyAPI_FUNC(node *) PyParser_ParseFileObject(
const char *enc,
grammar *g,
int start,
- char *ps1,
- char *ps2,
+ const char *ps1,
+ const char *ps2,
perrdetail *err_ret,
int *flags);
diff --git a/Include/pyport.h b/Include/pyport.h
index ca20b22..17dad41 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -673,8 +673,10 @@ extern char * _getpty(int *, int, mode_t, int);
/* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
functions, even though they are included in libutil. */
#include <termios.h>
-extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
-extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
+extern int openpty(int *, int *, char *,
+ const struct termios *, const struct winsize *);
+extern pid_t forkpty(int *, char *,
+ const struct termios *, const struct winsize *);
#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
index 7f67ab7..ec0565e 100644
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -261,10 +261,10 @@ PyAPI_DATA(PyThreadState *) _Py_Finalizing;
/* Stuff with no proper home (yet) */
#ifndef Py_LIMITED_API
-PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
+PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
#endif
PyAPI_DATA(int) (*PyOS_InputHook)(void);
-PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
+PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
#ifndef Py_LIMITED_API
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
#endif
diff --git a/Misc/NEWS b/Misc/NEWS
index 78efa31..f752a94 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -166,6 +166,8 @@ Library
C API
-----
+- Issue #1772673: The type of `char*` arguments now changed to `const char*`.
+
- Issue #16129: Added a `Py_SetStandardStreamEncoding` pre-initialization API
to allow embedding applications like Blender to force a particular
encoding and error handler for the standard IO streams (initial patch by
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 36beef1..b056d8b 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -248,7 +248,7 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para
current_param = PyDict_GetItemString(parameters, binding_name);
Py_XINCREF(current_param);
} else {
- current_param = PyMapping_GetItemString(parameters, (char*)binding_name);
+ current_param = PyMapping_GetItemString(parameters, binding_name);
}
if (!current_param) {
PyErr_Format(pysqlite_ProgrammingError, "You did not supply a value for binding %d.", i);
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
index 9e92db2..35723f4 100644
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -371,7 +371,7 @@ importmap(const char *modname, const char *symbol,
{
PyObject *o, *mod;
- mod = PyImport_ImportModule((char *)modname);
+ mod = PyImport_ImportModule(modname);
if (mod == NULL)
return -1;
diff --git a/Modules/readline.c b/Modules/readline.c
index d14a09f..f255a87 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -1043,7 +1043,7 @@ rlhandler(char *text)
extern PyThreadState* _PyOS_ReadlineTState;
static char *
-readline_until_enter_or_signal(char *prompt, int *signal)
+readline_until_enter_or_signal(const char *prompt, int *signal)
{
char * not_done_reading = "";
fd_set selectset;
@@ -1145,7 +1145,7 @@ readline_until_enter_or_signal(char *prompt, int *signal)
static char *
-call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
+call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{
size_t n;
char *p, *q;
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 078b4bc..d937892 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -223,7 +223,7 @@ PyObject_DelItem(PyObject *o, PyObject *key)
}
int
-PyObject_DelItemString(PyObject *o, char *key)
+PyObject_DelItemString(PyObject *o, const char *key)
{
PyObject *okey;
int ret;
@@ -1950,7 +1950,7 @@ PyMapping_Length(PyObject *o)
#define PyMapping_Length PyMapping_Size
PyObject *
-PyMapping_GetItemString(PyObject *o, char *key)
+PyMapping_GetItemString(PyObject *o, const char *key)
{
PyObject *okey, *r;
@@ -1966,7 +1966,7 @@ PyMapping_GetItemString(PyObject *o, char *key)
}
int
-PyMapping_SetItemString(PyObject *o, char *key, PyObject *value)
+PyMapping_SetItemString(PyObject *o, const char *key, PyObject *value)
{
PyObject *okey;
int r;
@@ -1985,7 +1985,7 @@ PyMapping_SetItemString(PyObject *o, char *key, PyObject *value)
}
int
-PyMapping_HasKeyString(PyObject *o, char *key)
+PyMapping_HasKeyString(PyObject *o, const char *key)
{
PyObject *v;
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 3a2906c..6132690 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -1347,7 +1347,7 @@ do_argstrip(PyBytesObject *self, int striptype, PyObject *args)
{
PyObject *sep = NULL;
- if (!PyArg_ParseTuple(args, (char *)stripformat[striptype], &sep))
+ if (!PyArg_ParseTuple(args, stripformat[striptype], &sep))
return NULL;
if (sep != NULL && sep != Py_None) {
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 79bbb8f..de5d746 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -121,11 +121,11 @@ BaseException_str(PyBaseExceptionObject *self)
static PyObject *
BaseException_repr(PyBaseExceptionObject *self)
{
- char *name;
- char *dot;
+ const char *name;
+ const char *dot;
- name = (char *)Py_TYPE(self)->tp_name;
- dot = strrchr(name, '.');
+ name = Py_TYPE(self)->tp_name;
+ dot = (const char *) strrchr(name, '.');
if (dot != NULL) name = dot+1;
return PyUnicode_FromFormat("%s%R", name, self->args);
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index f273b0b..596f909 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -26,8 +26,8 @@ extern "C" {
/* External C interface */
PyObject *
-PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding,
- char *errors, char *newline, int closefd)
+PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding,
+ const char *errors, const char *newline, int closefd)
{
PyObject *io, *stream;
_Py_IDENTIFIER(open);
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 876cd19..a5c0d1b 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -1941,10 +1941,10 @@ unsigned char _PyLong_DigitValue[256] = {
* string characters.
*/
static PyLongObject *
-long_from_binary_base(char **str, int base)
+long_from_binary_base(const char **str, int base)
{
- char *p = *str;
- char *start = p;
+ const char *p = *str;
+ const char *start = p;
int bits_per_char;
Py_ssize_t n;
PyLongObject *z;
@@ -2009,10 +2009,10 @@ long_from_binary_base(char **str, int base)
* If unsuccessful, NULL will be returned.
*/
PyObject *
-PyLong_FromString(char *str, char **pend, int base)
+PyLong_FromString(const char *str, char **pend, int base)
{
int sign = 1, error_if_nonzero = 0;
- char *start, *orig_str = str;
+ const char *start, *orig_str = str;
PyLongObject *z = NULL;
PyObject *strobj;
Py_ssize_t slen;
@@ -2147,7 +2147,7 @@ digit beyond the first.
int convwidth;
twodigits convmultmax, convmult;
digit *pz, *pzstop;
- char* scan;
+ const char* scan;
static double log_base_BASE[37] = {0.0e0,};
static int convwidth_base[37] = {0,};
@@ -2275,12 +2275,12 @@ digit beyond the first.
if (z == NULL)
return NULL;
if (pend != NULL)
- *pend = str;
+ *pend = (char *)str;
return (PyObject *) z;
onError:
if (pend != NULL)
- *pend = str;
+ *pend = (char *)str;
Py_XDECREF(z);
slen = strlen(orig_str) < 200 ? strlen(orig_str) : 200;
strobj = PyUnicode_FromStringAndSize(orig_str, slen);
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index b9e8e1e..ff806cf 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -11874,7 +11874,7 @@ do_argstrip(PyObject *self, int striptype, PyObject *args)
{
PyObject *sep = NULL;
- if (!PyArg_ParseTuple(args, (char *)stripformat[striptype], &sep))
+ if (!PyArg_ParseTuple(args, stripformat[striptype], &sep))
return NULL;
if (sep != NULL && sep != Py_None) {
diff --git a/Parser/grammar.c b/Parser/grammar.c
index f2a25ca..d4270de 100644
--- a/Parser/grammar.c
+++ b/Parser/grammar.c
@@ -29,7 +29,7 @@ newgrammar(int start)
}
dfa *
-adddfa(grammar *g, int type, char *name)
+adddfa(grammar *g, int type, const char *name)
{
dfa *d;
@@ -85,7 +85,7 @@ addarc(dfa *d, int from, int to, int lbl)
}
int
-addlabel(labellist *ll, int type, char *str)
+addlabel(labellist *ll, int type, const char *str)
{
int i;
label *lb;
@@ -111,7 +111,7 @@ addlabel(labellist *ll, int type, char *str)
/* Same, but rather dies than adds */
int
-findlabel(labellist *ll, int type, char *str)
+findlabel(labellist *ll, int type, const char *str)
{
int i;
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index 8bb35bd..a1c4b5c 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -109,7 +109,7 @@ my_fgets(char *buf, int len, FILE *fp)
/* Readline implementation using fgets() */
char *
-PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
+PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{
size_t n;
char *p, *pr;
@@ -170,13 +170,13 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
Note: Python expects in return a buffer allocated with PyMem_Malloc. */
-char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
+char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
/* Interface used by tokenizer.c and bltinmodule.c */
char *
-PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
+PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{
char *rv, *res;
size_t len;
diff --git a/Parser/parser.c b/Parser/parser.c
index fc102f2..56ec514 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -134,13 +134,13 @@ push(stack *s, int type, dfa *d, int newstate, int lineno, int col_offset)
/* PARSER PROPER */
static int
-classify(parser_state *ps, int type, char *str)
+classify(parser_state *ps, int type, const char *str)
{
grammar *g = ps->p_grammar;
int n = g->g_ll.ll_nlabels;
if (type == NAME) {
- char *s = str;
+ const char *s = str;
label *l = g->g_ll.ll_label;
int i;
for (i = n; i > 0; i--, l++) {
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index 2df9159..b4957b8 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -94,7 +94,8 @@ PyParser_ParseStringFlagsFilenameEx(const char *s, const char *filename_str,
node *
PyParser_ParseFile(FILE *fp, const char *filename, grammar *g, int start,
- char *ps1, char *ps2, perrdetail *err_ret)
+ const char *ps1, const char *ps2,
+ perrdetail *err_ret)
{
return PyParser_ParseFileFlags(fp, filename, NULL,
g, start, ps1, ps2, err_ret, 0);
@@ -103,7 +104,8 @@ PyParser_ParseFile(FILE *fp, const char *filename, grammar *g, int start,
node *
PyParser_ParseFileFlags(FILE *fp, const char *filename, const char *enc,
grammar *g, int start,
- char *ps1, char *ps2, perrdetail *err_ret, int flags)
+ const char *ps1, const char *ps2,
+ perrdetail *err_ret, int flags)
{
int iflags = flags;
return PyParser_ParseFileFlagsEx(fp, filename, enc, g, start, ps1,
@@ -113,15 +115,15 @@ PyParser_ParseFileFlags(FILE *fp, const char *filename, const char *enc,
node *
PyParser_ParseFileObject(FILE *fp, PyObject *filename,
const char *enc, grammar *g, int start,
- char *ps1, char *ps2, perrdetail *err_ret,
- int *flags)
+ const char *ps1, const char *ps2,
+ perrdetail *err_ret, int *flags)
{
struct tok_state *tok;
if (initerr(err_ret, filename) < 0)
return NULL;
- if ((tok = PyTokenizer_FromFile(fp, (char *)enc, ps1, ps2)) == NULL) {
+ if ((tok = PyTokenizer_FromFile(fp, enc, ps1, ps2)) == NULL) {
err_ret->error = E_NOMEM;
return NULL;
}
@@ -135,7 +137,8 @@ PyParser_ParseFileObject(FILE *fp, PyObject *filename,
node *
PyParser_ParseFileFlagsEx(FILE *fp, const char *filename,
const char *enc, grammar *g, int start,
- char *ps1, char *ps2, perrdetail *err_ret, int *flags)
+ const char *ps1, const char *ps2,
+ perrdetail *err_ret, int *flags)
{
node *n;
PyObject *fileobj = NULL;
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c
index a624dd2..017a4f9 100644
--- a/Parser/pgenmain.c
+++ b/Parser/pgenmain.c
@@ -138,7 +138,7 @@ Py_FatalError(const char *msg)
/* No-nonsense my_readline() for tokenizer.c */
char *
-PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
+PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{
size_t n = 1000;
char *p = (char *)PyMem_MALLOC(n);
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index dafb4bd..5bf7e84 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -31,7 +31,7 @@
|| c == '_'\
|| (c >= 128))
-extern char *PyOS_Readline(FILE *, FILE *, char *);
+extern char *PyOS_Readline(FILE *, FILE *, const char *);
/* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF;
NULL if interrupted */
@@ -780,7 +780,7 @@ PyTokenizer_FromString(const char *str, int exec_input)
struct tok_state *tok = tok_new();
if (tok == NULL)
return NULL;
- str = (char *)decode_str(str, exec_input, tok);
+ str = decode_str(str, exec_input, tok);
if (str == NULL) {
PyTokenizer_Free(tok);
return NULL;
@@ -823,7 +823,8 @@ PyTokenizer_FromUTF8(const char *str, int exec_input)
/* Set up tokenizer for file */
struct tok_state *
-PyTokenizer_FromFile(FILE *fp, char* enc, char *ps1, char *ps2)
+PyTokenizer_FromFile(FILE *fp, const char* enc,
+ const char *ps1, const char *ps2)
{
struct tok_state *tok = tok_new();
if (tok == NULL)
diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h
index ed1f3aa..1ce6eeb 100644
--- a/Parser/tokenizer.h
+++ b/Parser/tokenizer.h
@@ -35,7 +35,7 @@ struct tok_state {
int indstack[MAXINDENT]; /* Stack of indents */
int atbol; /* Nonzero if at begin of new line */
int pendin; /* Pending indents (if > 0) or dedents (if < 0) */
- char *prompt, *nextprompt; /* For interactive prompting */
+ const char *prompt, *nextprompt; /* For interactive prompting */
int lineno; /* Current line number */
int level; /* () [] {} Parentheses nesting level */
/* Used to allow free continuations inside them */
@@ -69,8 +69,8 @@ struct tok_state {
extern struct tok_state *PyTokenizer_FromString(const char *, int);
extern struct tok_state *PyTokenizer_FromUTF8(const char *, int);
-extern struct tok_state *PyTokenizer_FromFile(FILE *, char*,
- char *, char *);
+extern struct tok_state *PyTokenizer_FromFile(FILE *, const char*,
+ const char *, const char *);
extern void PyTokenizer_Free(struct tok_state *);
extern int PyTokenizer_Get(struct tok_state *, char **, char **);
extern char * PyTokenizer_RestoreEncoding(struct tok_state* tok,
diff --git a/Python/ast.c b/Python/ast.c
index 9ffe3c7..3bd24fd 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -3651,18 +3651,16 @@ parsenumber(struct compiling *c, const char *s)
end = s + strlen(s) - 1;
imflag = *end == 'j' || *end == 'J';
if (s[0] == '0') {
- x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
+ x = (long) PyOS_strtoul(s, (char **)&end, 0);
if (x < 0 && errno == 0) {
- return PyLong_FromString((char *)s,
- (char **)0,
- 0);
+ return PyLong_FromString(s, (char **)0, 0);
}
}
else
- x = PyOS_strtol((char *)s, (char **)&end, 0);
+ x = PyOS_strtol(s, (char **)&end, 0);
if (*end == '\0') {
if (errno != 0)
- return PyLong_FromString((char *)s, (char **)0, 0);
+ return PyLong_FromString(s, (char **)0, 0);
return PyLong_FromLong(x);
}
/* XXX Huge floats may silently fail */
@@ -3685,8 +3683,8 @@ parsenumber(struct compiling *c, const char *s)
static PyObject *
decode_utf8(struct compiling *c, const char **sPtr, const char *end)
{
- char *s, *t;
- t = s = (char *)*sPtr;
+ const char *s, *t;
+ t = s = *sPtr;
/* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */
while (s < end && (*s & 0x80)) s++;
*sPtr = s;
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 3f270b4..4713874 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1335,7 +1335,7 @@ min_max(PyObject *args, PyObject *kwds, int op)
if (positional)
v = args;
- else if (!PyArg_UnpackTuple(args, (char *)name, 1, 1, &v))
+ else if (!PyArg_UnpackTuple(args, name, 1, 1, &v))
return NULL;
emptytuple = PyTuple_New(0);
diff --git a/Python/codecs.c b/Python/codecs.c
index cb9f0d8..c541ba0 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -441,7 +441,7 @@ int PyCodec_RegisterError(const char *name, PyObject *error)
return -1;
}
return PyDict_SetItemString(interp->codec_error_registry,
- (char *)name, error);
+ name, error);
}
/* Lookup the error handling callback function registered under the
@@ -457,7 +457,7 @@ PyObject *PyCodec_LookupError(const char *name)
if (name==NULL)
name = "strict";
- handler = PyDict_GetItemString(interp->codec_error_registry, (char *)name);
+ handler = PyDict_GetItemString(interp->codec_error_registry, name);
if (!handler)
PyErr_Format(PyExc_LookupError, "unknown error handler name '%.400s'", name);
else
diff --git a/Python/import.c b/Python/import.c
index 1a162ee..c96106f 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -517,7 +517,7 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
}
int
-_PyImport_FixupBuiltin(PyObject *mod, char *name)
+_PyImport_FixupBuiltin(PyObject *mod, const char *name)
{
int res;
PyObject *nameobj;
@@ -656,22 +656,23 @@ remove_module(PyObject *name)
* interface. The other two exist primarily for backward compatibility.
*/
PyObject *
-PyImport_ExecCodeModule(char *name, PyObject *co)
+PyImport_ExecCodeModule(const char *name, PyObject *co)
{
return PyImport_ExecCodeModuleWithPathnames(
name, co, (char *)NULL, (char *)NULL);
}
PyObject *
-PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
+PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
{
return PyImport_ExecCodeModuleWithPathnames(
name, co, pathname, (char *)NULL);
}
PyObject *
-PyImport_ExecCodeModuleWithPathnames(char *name, PyObject *co, char *pathname,
- char *cpathname)
+PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
+ const char *pathname,
+ const char *cpathname)
{
PyObject *m = NULL;
PyObject *nameobj, *pathobj = NULL, *cpathobj = NULL;
@@ -1019,7 +1020,7 @@ get_frozen_object(PyObject *name)
size = p->size;
if (size < 0)
size = -size;
- return PyMarshal_ReadObjectFromString((char *)p->code, size);
+ return PyMarshal_ReadObjectFromString((const char *)p->code, size);
}
static PyObject *
@@ -1071,7 +1072,7 @@ PyImport_ImportFrozenModuleObject(PyObject *name)
ispackage = (size < 0);
if (ispackage)
size = -size;
- co = PyMarshal_ReadObjectFromString((char *)p->code, size);
+ co = PyMarshal_ReadObjectFromString((const char *)p->code, size);
if (co == NULL)
return -1;
if (!PyCode_Check(co)) {
@@ -1113,7 +1114,7 @@ err_return:
}
int
-PyImport_ImportFrozenModule(char *name)
+PyImport_ImportFrozenModule(const char *name)
{
PyObject *nameobj;
int ret;
diff --git a/Python/marshal.c b/Python/marshal.c
index f94276a..4401afb 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -1466,15 +1466,15 @@ PyMarshal_ReadObjectFromFile(FILE *fp)
}
PyObject *
-PyMarshal_ReadObjectFromString(char *str, Py_ssize_t len)
+PyMarshal_ReadObjectFromString(const char *str, Py_ssize_t len)
{
RFILE rf;
PyObject *result;
rf.fp = NULL;
rf.readable = NULL;
rf.current_filename = NULL;
- rf.ptr = str;
- rf.end = str + len;
+ rf.ptr = (char *)str;
+ rf.end = (char *)str + len;
rf.buf = NULL;
rf.depth = 0;
rf.refs = PyList_New(0);
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index 725f07c..98429d4 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -92,7 +92,7 @@ static int digitlimit[] = {
** exceptions - we don't check for them.
*/
unsigned long
-PyOS_strtoul(char *str, char **ptr, int base)
+PyOS_strtoul(const char *str, char **ptr, int base)
{
unsigned long result = 0; /* return value of the function */
int c; /* current input character */
@@ -111,7 +111,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* there must be at least one digit after 0x */
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
++str;
@@ -120,7 +120,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* there must be at least one digit after 0o */
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
++str;
@@ -129,7 +129,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* there must be at least one digit after 0b */
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
++str;
@@ -141,7 +141,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
while (Py_ISSPACE(Py_CHARMASK(*str)))
++str;
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
}
@@ -157,7 +157,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* there must be at least one digit after 0x */
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
++str;
@@ -171,7 +171,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* there must be at least one digit after 0o */
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
++str;
@@ -185,7 +185,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* there must be at least one digit after 0b */
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
++str;
@@ -197,7 +197,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* catch silly bases */
if (base < 2 || base > 36) {
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return 0;
}
@@ -239,7 +239,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
/* set pointer to point to the last character scanned */
if (ptr)
- *ptr = str;
+ *ptr = (char *)str;
return result;
@@ -248,7 +248,7 @@ overflowed:
/* spool through remaining digit characters */
while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base)
++str;
- *ptr = str;
+ *ptr = (char *)str;
}
errno = ERANGE;
return (unsigned long)-1;
@@ -260,7 +260,7 @@ overflowed:
#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN)
long
-PyOS_strtol(char *str, char **ptr, int base)
+PyOS_strtol(const char *str, char **ptr, int base)
{
long result;
unsigned long uresult;