Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b382b84

Browse files
committed
Add const to some strings that are not modified
1 parent cd79596 commit b382b84

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

Include/pyerrors.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);
167167
PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
168168
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
169169
PyObject *, PyObject *);
170-
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, char *);
170+
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(PyObject *, const char *);
171171
#ifdef Py_WIN_WIDE_FILENAMES
172172
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
173-
PyObject *, Py_UNICODE *);
173+
PyObject *, const Py_UNICODE *);
174174
#endif /* Py_WIN_WIDE_FILENAMES */
175175

176176
PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...);
@@ -198,13 +198,13 @@ PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
198198

199199
/* Export the old function so that the existing API remains available: */
200200
PyAPI_FUNC(void) PyErr_BadInternalCall(void);
201-
PyAPI_FUNC(void) _PyErr_BadInternalCall(char *filename, int lineno);
201+
PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);
202202
/* Mask the old API with a call to the new API for code compiled under
203203
Python 2.0: */
204204
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
205205

206206
/* Function to create a new exception */
207-
PyAPI_FUNC(PyObject *) PyErr_NewException(char *name, PyObject *base,
207+
PyAPI_FUNC(PyObject *) PyErr_NewException(const char *name, PyObject *base,
208208
PyObject *dict);
209209
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
210210

Python/errors.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject)
348348

349349

350350
PyObject *
351-
PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
351+
PyErr_SetFromErrnoWithFilename(PyObject *exc, const char *filename)
352352
{
353353
PyObject *name = filename ? PyUnicode_FromString(filename) : NULL;
354354
PyObject *result = PyErr_SetFromErrnoWithFilenameObject(exc, name);
@@ -358,7 +358,7 @@ PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
358358

359359
#ifdef Py_WIN_WIDE_FILENAMES
360360
PyObject *
361-
PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, Py_UNICODE *filename)
361+
PyErr_SetFromErrnoWithUnicodeFilename(PyObject *exc, const Py_UNICODE *filename)
362362
{
363363
PyObject *name = filename ?
364364
PyUnicode_FromUnicode(filename, wcslen(filename)) :
@@ -494,7 +494,7 @@ PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename(
494494
#endif /* MS_WINDOWS */
495495

496496
void
497-
_PyErr_BadInternalCall(char *filename, int lineno)
497+
_PyErr_BadInternalCall(const char *filename, int lineno)
498498
{
499499
PyErr_Format(PyExc_SystemError,
500500
"%s:%d: bad argument to internal function",
@@ -536,9 +536,9 @@ PyErr_Format(PyObject *exception, const char *format, ...)
536536

537537

538538
PyObject *
539-
PyErr_NewException(char *name, PyObject *base, PyObject *dict)
539+
PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
540540
{
541-
char *dot;
541+
const char *dot;
542542
PyObject *modulename = NULL;
543543
PyObject *classname = NULL;
544544
PyObject *mydict = NULL;

0 commit comments

Comments
 (0)