From bed678449f55a47fad914fa9e04df547c240f810 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Sat, 27 Oct 2007 04:00:45 +0000 Subject: [PATCH] Get rid of more uses of string and use unicode --- Doc/includes/noddy2.c | 8 ++++---- Doc/includes/noddy3.c | 12 ++++++------ Doc/includes/noddy4.c | 8 ++++---- Doc/includes/run-func.c | 2 +- Modules/_lsprof.c | 5 +---- Objects/exceptions.c | 2 +- Objects/frameobject.c | 2 +- 7 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Doc/includes/noddy2.c b/Doc/includes/noddy2.c index 2caf9855c64..eaa355fa491 100644 --- a/Doc/includes/noddy2.c +++ b/Doc/includes/noddy2.c @@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self = (Noddy *)type->tp_alloc(type, 0); if (self != NULL) { - self->first = PyString_FromString(""); + self->first = PyUnicode_FromString(""); if (self->first == NULL) { Py_DECREF(self); return NULL; } - self->last = PyString_FromString(""); + self->last = PyUnicode_FromString(""); if (self->last == NULL) { Py_DECREF(self); @@ -90,7 +90,7 @@ Noddy_name(Noddy* self) PyObject *args, *result; if (format == NULL) { - format = PyString_FromString("%s %s"); + format = PyUnicode_FromString("%s %s"); if (format == NULL) return NULL; } @@ -109,7 +109,7 @@ Noddy_name(Noddy* self) if (args == NULL) return NULL; - result = PyString_Format(format, args); + result = PyUnicode_Format(format, args); Py_DECREF(args); return result; diff --git a/Doc/includes/noddy3.c b/Doc/includes/noddy3.c index 60260ada52f..3a1c0c2beb1 100644 --- a/Doc/includes/noddy3.c +++ b/Doc/includes/noddy3.c @@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self = (Noddy *)type->tp_alloc(type, 0); if (self != NULL) { - self->first = PyString_FromString(""); + self->first = PyUnicode_FromString(""); if (self->first == NULL) { Py_DECREF(self); return NULL; } - self->last = PyString_FromString(""); + self->last = PyUnicode_FromString(""); if (self->last == NULL) { Py_DECREF(self); @@ -93,7 +93,7 @@ Noddy_setfirst(Noddy *self, PyObject *value, void *closure) return -1; } - if (! PyString_Check(value)) { + if (! PyUnicode_Check(value)) { PyErr_SetString(PyExc_TypeError, "The first attribute value must be a string"); return -1; @@ -121,7 +121,7 @@ Noddy_setlast(Noddy *self, PyObject *value, void *closure) return -1; } - if (! PyString_Check(value)) { + if (! PyUnicode_Check(value)) { PyErr_SetString(PyExc_TypeError, "The last attribute value must be a string"); return -1; @@ -153,7 +153,7 @@ Noddy_name(Noddy* self) PyObject *args, *result; if (format == NULL) { - format = PyString_FromString("%s %s"); + format = PyUnicode_FromString("%s %s"); if (format == NULL) return NULL; } @@ -162,7 +162,7 @@ Noddy_name(Noddy* self) if (args == NULL) return NULL; - result = PyString_Format(format, args); + result = PyUnicode_Format(format, args); Py_DECREF(args); return result; diff --git a/Doc/includes/noddy4.c b/Doc/includes/noddy4.c index 878e0861d87..ac0b1f4d407 100644 --- a/Doc/includes/noddy4.c +++ b/Doc/includes/noddy4.c @@ -57,14 +57,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self = (Noddy *)type->tp_alloc(type, 0); if (self != NULL) { - self->first = PyString_FromString(""); + self->first = PyUnicode_FromString(""); if (self->first == NULL) { Py_DECREF(self); return NULL; } - self->last = PyString_FromString(""); + self->last = PyUnicode_FromString(""); if (self->last == NULL) { Py_DECREF(self); @@ -124,7 +124,7 @@ Noddy_name(Noddy* self) PyObject *args, *result; if (format == NULL) { - format = PyString_FromString("%s %s"); + format = PyUnicode_FromString("%s %s"); if (format == NULL) return NULL; } @@ -143,7 +143,7 @@ Noddy_name(Noddy* self) if (args == NULL) return NULL; - result = PyString_Format(format, args); + result = PyUnicode_Format(format, args); Py_DECREF(args); return result; diff --git a/Doc/includes/run-func.c b/Doc/includes/run-func.c index 5a7df0d9805..e4f5a276241 100644 --- a/Doc/includes/run-func.c +++ b/Doc/includes/run-func.c @@ -13,7 +13,7 @@ main(int argc, char *argv[]) } Py_Initialize(); - pName = PyString_FromString(argv[1]); + pName = PyUnicode_FromString(argv[1]); /* Error checking of pName left out */ pModule = PyImport_Import(pName); diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index a5740e79d7e..7e85dcf8d4b 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -179,10 +179,7 @@ normalizeUserObj(PyObject *obj) /* built-in function: look up the module name */ PyObject *mod = fn->m_module; const char *modname; - if (mod && PyString_Check(mod)) { - modname = PyString_AS_STRING(mod); - } - else if (mod && PyUnicode_Check(mod)) { + if (mod && PyUnicode_Check(mod)) { modname = PyUnicode_AsString(mod); } else if (mod && PyModule_Check(mod)) { diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 041cf9d1049..abe4bde084c 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -1882,7 +1882,7 @@ _PyExc_Init(void) (PyBaseExceptionObject *)PyExc_RecursionErrorInst; PyObject *args_tuple; PyObject *exc_message; - exc_message = PyString_FromString("maximum recursion depth exceeded"); + exc_message = PyUnicode_FromString("maximum recursion depth exceeded"); if (!exc_message) Py_FatalError("cannot allocate argument for RuntimeError " "pre-allocation"); diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 7ec7ed5443b..cf41ddda00b 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -721,7 +721,7 @@ map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values, for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); PyObject *value = values[j]; - assert(PyString_Check(key)/*XXX this should go*/ || PyUnicode_Check(key)); + assert(PyUnicode_Check(key)); if (deref) { assert(PyCell_Check(value)); value = PyCell_GET(value);