@@ -288,13 +288,13 @@ strings, so we provide a new method::
288288
289289 self = (Noddy *)type->tp_alloc(type, 0);
290290 if (self != NULL) {
291- self->first = PyString_FromString ("");
291+ self->first = PyUnicode_FromString ("");
292292 if (self->first == NULL) {
293293 Py_DECREF(self);
294294 return NULL;
295295 }
296296
297- self->last = PyString_FromString ("");
297+ self->last = PyUnicode_FromString ("");
298298 if (self->last == NULL) {
299299 Py_DECREF(self);
300300 return NULL;
@@ -540,9 +540,9 @@ getting and setting the :attr:`first` attribute::
540540 return -1;
541541 }
542542
543- if (! PyString_Check (value)) {
543+ if (! PyUnicode_Check (value)) {
544544 PyErr_SetString(PyExc_TypeError,
545- "The first attribute value must be a string ");
545+ "The first attribute value must be a str ");
546546 return -1;
547547 }
548548
@@ -1005,8 +1005,8 @@ example::
10051005 static PyObject *
10061006 newdatatype_repr(newdatatypeobject * obj)
10071007 {
1008- return PyString_FromFormat ("Repr-ified_newdatatype{{size:\%d}}",
1009- obj->obj_UnderlyingDatatypePtr->size);
1008+ return PyUnicode_FromFormat ("Repr-ified_newdatatype{{size:\%d}}",
1009+ obj->obj_UnderlyingDatatypePtr->size);
10101010 }
10111011
10121012If no :attr: `tp_repr ` handler is specified, the interpreter will supply a
@@ -1025,8 +1025,8 @@ Here is a simple example::
10251025 static PyObject *
10261026 newdatatype_str(newdatatypeobject * obj)
10271027 {
1028- return PyString_FromFormat ("Stringified_newdatatype{{size:\%d}}",
1029- obj->obj_UnderlyingDatatypePtr->size);
1028+ return PyUnicode_FromFormat ("Stringified_newdatatype{{size:\%d}}",
1029+ obj->obj_UnderlyingDatatypePtr->size);
10301030 }
10311031
10321032
@@ -1342,11 +1342,10 @@ Here is a desultory example of the implementation of the call function. ::
13421342 if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
13431343 return NULL;
13441344 }
1345- result = PyString_FromFormat (
1345+ result = PyUnicode_FromFormat (
13461346 "Returning -- value: [\%d] arg1: [\%s] arg2: [\%s] arg3: [\%s]\n",
13471347 obj->obj_UnderlyingDatatypePtr->size,
13481348 arg1, arg2, arg3);
1349- printf("\%s", PyString_AS_STRING(result));
13501349 return result;
13511350 }
13521351
0 commit comments