Skip to content

Commit 312e10d

Browse files
committed
Get rid of more uses of string and use const in a few places.
1 parent a9ea3d9 commit 312e10d

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Include/moduleobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ PyAPI_DATA(PyTypeObject) PyModule_Type;
1414

1515
PyAPI_FUNC(PyObject *) PyModule_New(const char *);
1616
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
17-
PyAPI_FUNC(char *) PyModule_GetName(PyObject *);
18-
PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *);
17+
PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
18+
PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
1919
PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
2020

2121
#ifdef __cplusplus

Objects/moduleobject.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ PyModule_GetDict(PyObject *m)
5454
return d;
5555
}
5656

57-
char *
57+
const char *
5858
PyModule_GetName(PyObject *m)
5959
{
6060
PyObject *d;
@@ -79,7 +79,7 @@ PyModule_GetName(PyObject *m)
7979
return PyString_AsString(nameobj);
8080
}
8181

82-
char *
82+
const char *
8383
PyModule_GetFilename(PyObject *m)
8484
{
8585
PyObject *d;
@@ -120,8 +120,8 @@ _PyModule_Clear(PyObject *m)
120120
/* First, clear only names starting with a single underscore */
121121
pos = 0;
122122
while (PyDict_Next(d, &pos, &key, &value)) {
123-
if (value != Py_None && PyString_Check(key)) {
124-
char *s = PyString_AsString(key);
123+
if (value != Py_None && PyUnicode_Check(key)) {
124+
const char *s = PyUnicode_AsString(key);
125125
if (s[0] == '_' && s[1] != '_') {
126126
if (Py_VerboseFlag > 1)
127127
PySys_WriteStderr("# clear[1] %s\n", s);
@@ -133,8 +133,8 @@ _PyModule_Clear(PyObject *m)
133133
/* Next, clear all names except for __builtins__ */
134134
pos = 0;
135135
while (PyDict_Next(d, &pos, &key, &value)) {
136-
if (value != Py_None && PyString_Check(key)) {
137-
char *s = PyString_AsString(key);
136+
if (value != Py_None && PyUnicode_Check(key)) {
137+
const char *s = PyUnicode_AsString(key);
138138
if (s[0] != '_' || strcmp(s, "__builtins__") != 0) {
139139
if (Py_VerboseFlag > 1)
140140
PySys_WriteStderr("# clear[2] %s\n", s);
@@ -187,8 +187,8 @@ module_dealloc(PyModuleObject *m)
187187
static PyObject *
188188
module_repr(PyModuleObject *m)
189189
{
190-
char *name;
191-
char *filename;
190+
const char *name;
191+
const char *filename;
192192

193193
name = PyModule_GetName((PyObject *)m);
194194
if (name == NULL) {

0 commit comments

Comments
 (0)