Skip to content

Commit bed6784

Browse files
committed
Get rid of more uses of string and use unicode
1 parent 841e122 commit bed6784

7 files changed

Lines changed: 18 additions & 21 deletions

File tree

Doc/includes/noddy2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2323

2424
self = (Noddy *)type->tp_alloc(type, 0);
2525
if (self != NULL) {
26-
self->first = PyString_FromString("");
26+
self->first = PyUnicode_FromString("");
2727
if (self->first == NULL)
2828
{
2929
Py_DECREF(self);
3030
return NULL;
3131
}
3232

33-
self->last = PyString_FromString("");
33+
self->last = PyUnicode_FromString("");
3434
if (self->last == NULL)
3535
{
3636
Py_DECREF(self);
@@ -90,7 +90,7 @@ Noddy_name(Noddy* self)
9090
PyObject *args, *result;
9191

9292
if (format == NULL) {
93-
format = PyString_FromString("%s %s");
93+
format = PyUnicode_FromString("%s %s");
9494
if (format == NULL)
9595
return NULL;
9696
}
@@ -109,7 +109,7 @@ Noddy_name(Noddy* self)
109109
if (args == NULL)
110110
return NULL;
111111

112-
result = PyString_Format(format, args);
112+
result = PyUnicode_Format(format, args);
113113
Py_DECREF(args);
114114

115115
return result;

Doc/includes/noddy3.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2323

2424
self = (Noddy *)type->tp_alloc(type, 0);
2525
if (self != NULL) {
26-
self->first = PyString_FromString("");
26+
self->first = PyUnicode_FromString("");
2727
if (self->first == NULL)
2828
{
2929
Py_DECREF(self);
3030
return NULL;
3131
}
3232

33-
self->last = PyString_FromString("");
33+
self->last = PyUnicode_FromString("");
3434
if (self->last == NULL)
3535
{
3636
Py_DECREF(self);
@@ -93,7 +93,7 @@ Noddy_setfirst(Noddy *self, PyObject *value, void *closure)
9393
return -1;
9494
}
9595

96-
if (! PyString_Check(value)) {
96+
if (! PyUnicode_Check(value)) {
9797
PyErr_SetString(PyExc_TypeError,
9898
"The first attribute value must be a string");
9999
return -1;
@@ -121,7 +121,7 @@ Noddy_setlast(Noddy *self, PyObject *value, void *closure)
121121
return -1;
122122
}
123123

124-
if (! PyString_Check(value)) {
124+
if (! PyUnicode_Check(value)) {
125125
PyErr_SetString(PyExc_TypeError,
126126
"The last attribute value must be a string");
127127
return -1;
@@ -153,7 +153,7 @@ Noddy_name(Noddy* self)
153153
PyObject *args, *result;
154154

155155
if (format == NULL) {
156-
format = PyString_FromString("%s %s");
156+
format = PyUnicode_FromString("%s %s");
157157
if (format == NULL)
158158
return NULL;
159159
}
@@ -162,7 +162,7 @@ Noddy_name(Noddy* self)
162162
if (args == NULL)
163163
return NULL;
164164

165-
result = PyString_Format(format, args);
165+
result = PyUnicode_Format(format, args);
166166
Py_DECREF(args);
167167

168168
return result;

Doc/includes/noddy4.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
5757

5858
self = (Noddy *)type->tp_alloc(type, 0);
5959
if (self != NULL) {
60-
self->first = PyString_FromString("");
60+
self->first = PyUnicode_FromString("");
6161
if (self->first == NULL)
6262
{
6363
Py_DECREF(self);
6464
return NULL;
6565
}
6666

67-
self->last = PyString_FromString("");
67+
self->last = PyUnicode_FromString("");
6868
if (self->last == NULL)
6969
{
7070
Py_DECREF(self);
@@ -124,7 +124,7 @@ Noddy_name(Noddy* self)
124124
PyObject *args, *result;
125125

126126
if (format == NULL) {
127-
format = PyString_FromString("%s %s");
127+
format = PyUnicode_FromString("%s %s");
128128
if (format == NULL)
129129
return NULL;
130130
}
@@ -143,7 +143,7 @@ Noddy_name(Noddy* self)
143143
if (args == NULL)
144144
return NULL;
145145

146-
result = PyString_Format(format, args);
146+
result = PyUnicode_Format(format, args);
147147
Py_DECREF(args);
148148

149149
return result;

Doc/includes/run-func.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ main(int argc, char *argv[])
1313
}
1414

1515
Py_Initialize();
16-
pName = PyString_FromString(argv[1]);
16+
pName = PyUnicode_FromString(argv[1]);
1717
/* Error checking of pName left out */
1818

1919
pModule = PyImport_Import(pName);

Modules/_lsprof.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,7 @@ normalizeUserObj(PyObject *obj)
179179
/* built-in function: look up the module name */
180180
PyObject *mod = fn->m_module;
181181
const char *modname;
182-
if (mod && PyString_Check(mod)) {
183-
modname = PyString_AS_STRING(mod);
184-
}
185-
else if (mod && PyUnicode_Check(mod)) {
182+
if (mod && PyUnicode_Check(mod)) {
186183
modname = PyUnicode_AsString(mod);
187184
}
188185
else if (mod && PyModule_Check(mod)) {

Objects/exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ _PyExc_Init(void)
18821882
(PyBaseExceptionObject *)PyExc_RecursionErrorInst;
18831883
PyObject *args_tuple;
18841884
PyObject *exc_message;
1885-
exc_message = PyString_FromString("maximum recursion depth exceeded");
1885+
exc_message = PyUnicode_FromString("maximum recursion depth exceeded");
18861886
if (!exc_message)
18871887
Py_FatalError("cannot allocate argument for RuntimeError "
18881888
"pre-allocation");

Objects/frameobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
721721
for (j = nmap; --j >= 0; ) {
722722
PyObject *key = PyTuple_GET_ITEM(map, j);
723723
PyObject *value = values[j];
724-
assert(PyString_Check(key)/*XXX this should go*/ || PyUnicode_Check(key));
724+
assert(PyUnicode_Check(key));
725725
if (deref) {
726726
assert(PyCell_Check(value));
727727
value = PyCell_GET(value);

0 commit comments

Comments
 (0)