Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 42812:a99ec4befda8
Add const to input string parameters
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sat, 25 Aug 2007 00:32:45 +0000 |
| parents | 8bad8722f0e6 |
| children | f81d94c05a0e |
comparison
equal
deleted
inserted
replaced
| 42811:2c2e905894a3 | 42812:a99ec4befda8 |
|---|---|
| 44 #include <locale.h> | 44 #include <locale.h> |
| 45 #include <langinfo.h> | 45 #include <langinfo.h> |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 PyObject * | 48 PyObject * |
| 49 PySys_GetObject(char *name) | 49 PySys_GetObject(const char *name) |
| 50 { | 50 { |
| 51 PyThreadState *tstate = PyThreadState_GET(); | 51 PyThreadState *tstate = PyThreadState_GET(); |
| 52 PyObject *sd = tstate->interp->sysdict; | 52 PyObject *sd = tstate->interp->sysdict; |
| 53 if (sd == NULL) | 53 if (sd == NULL) |
| 54 return NULL; | 54 return NULL; |
| 55 return PyDict_GetItemString(sd, name); | 55 return PyDict_GetItemString(sd, name); |
| 56 } | 56 } |
| 57 | 57 |
| 58 int | 58 int |
| 59 PySys_SetObject(char *name, PyObject *v) | 59 PySys_SetObject(const char *name, PyObject *v) |
| 60 { | 60 { |
| 61 PyThreadState *tstate = PyThreadState_GET(); | 61 PyThreadState *tstate = PyThreadState_GET(); |
| 62 PyObject *sd = tstate->interp->sysdict; | 62 PyObject *sd = tstate->interp->sysdict; |
| 63 if (v == NULL) { | 63 if (v == NULL) { |
| 64 if (PyDict_GetItemString(sd, name) == NULL) | 64 if (PyDict_GetItemString(sd, name) == NULL) |
| 817 return; | 817 return; |
| 818 PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL); | 818 PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL); |
| 819 } | 819 } |
| 820 | 820 |
| 821 void | 821 void |
| 822 PySys_AddWarnOption(char *s) | 822 PySys_AddWarnOption(const char *s) |
| 823 { | 823 { |
| 824 PyObject *str; | 824 PyObject *str; |
| 825 | 825 |
| 826 if (warnoptions == NULL || !PyList_Check(warnoptions)) { | 826 if (warnoptions == NULL || !PyList_Check(warnoptions)) { |
| 827 Py_XDECREF(warnoptions); | 827 Py_XDECREF(warnoptions); |
| 1126 return NULL; | 1126 return NULL; |
| 1127 return m; | 1127 return m; |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 static PyObject * | 1130 static PyObject * |
| 1131 makepathobject(char *path, int delim) | 1131 makepathobject(const char *path, int delim) |
| 1132 { | 1132 { |
| 1133 int i, n; | 1133 int i, n; |
| 1134 char *p; | 1134 const char *p; |
| 1135 PyObject *v, *w; | 1135 PyObject *v, *w; |
| 1136 | 1136 |
| 1137 n = 1; | 1137 n = 1; |
| 1138 p = path; | 1138 p = path; |
| 1139 while ((p = strchr(p, delim)) != NULL) { | 1139 while ((p = strchr(p, delim)) != NULL) { |
| 1159 } | 1159 } |
| 1160 return v; | 1160 return v; |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 void | 1163 void |
| 1164 PySys_SetPath(char *path) | 1164 PySys_SetPath(const char *path) |
| 1165 { | 1165 { |
| 1166 PyObject *v; | 1166 PyObject *v; |
| 1167 if ((v = makepathobject(path, DELIM)) == NULL) | 1167 if ((v = makepathobject(path, DELIM)) == NULL) |
| 1168 Py_FatalError("can't create sys.path"); | 1168 Py_FatalError("can't create sys.path"); |
| 1169 if (PySys_SetObject("path", v) != 0) | 1169 if (PySys_SetObject("path", v) != 0) |
