@@ -287,14 +287,14 @@ strings, so we provide a new method::
287287
288288 self = (Noddy *)type->tp_alloc(type, 0);
289289 if (self != NULL) {
290- self->first = PyString_FromString ("");
290+ self->first = PyUnicode_FromString ("");
291291 if (self->first == NULL)
292292 {
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 {
300300 Py_DECREF(self);
@@ -449,7 +449,7 @@ concatenation of the first and last names. ::
449449 PyObject *args, *result;
450450
451451 if (format == NULL) {
452- format = PyString_FromString ("%s %s");
452+ format = PyUnicode_FromString ("%s %s");
453453 if (format == NULL)
454454 return NULL;
455455 }
@@ -468,7 +468,7 @@ concatenation of the first and last names. ::
468468 if (args == NULL)
469469 return NULL;
470470
471- result = PyString_Format (format, args);
471+ result = PyUnicode_Format (format, args);
472472 Py_DECREF(args);
473473
474474 return result;
@@ -557,9 +557,9 @@ getting and setting the :attr:`first` attribute::
557557 return -1;
558558 }
559559
560- if (! PyString_Check (value)) {
560+ if (! PyUnicode_Check (value)) {
561561 PyErr_SetString(PyExc_TypeError,
562- "The first attribute value must be a string ");
562+ "The first attribute value must be a str ");
563563 return -1;
564564 }
565565
@@ -1022,8 +1022,8 @@ example::
10221022 static PyObject *
10231023 newdatatype_repr(newdatatypeobject * obj)
10241024 {
1025- return PyString_FromFormat ("Repr-ified_newdatatype{{size:\%d}}",
1026- obj->obj_UnderlyingDatatypePtr->size);
1025+ return PyUnicode_FromFormat ("Repr-ified_newdatatype{{size:\%d}}",
1026+ obj->obj_UnderlyingDatatypePtr->size);
10271027 }
10281028
10291029If no :attr: `tp_repr ` handler is specified, the interpreter will supply a
@@ -1042,8 +1042,8 @@ Here is a simple example::
10421042 static PyObject *
10431043 newdatatype_str(newdatatypeobject * obj)
10441044 {
1045- return PyString_FromFormat ("Stringified_newdatatype{{size:\%d}}",
1046- obj->obj_UnderlyingDatatypePtr->size);
1045+ return PyUnicode_FromFormat ("Stringified_newdatatype{{size:\%d}}",
1046+ obj->obj_UnderlyingDatatypePtr->size);
10471047 }
10481048
10491049
@@ -1364,11 +1364,10 @@ Here is a desultory example of the implementation of the call function. ::
13641364 if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
13651365 return NULL;
13661366 }
1367- result = PyString_FromFormat (
1367+ result = PyUnicode_FromFormat (
13681368 "Returning -- value: [\%d] arg1: [\%s] arg2: [\%s] arg3: [\%s]\n",
13691369 obj->obj_UnderlyingDatatypePtr->size,
13701370 arg1, arg2, arg3);
1371- printf("\%s", PyString_AS_STRING(result));
13721371 return result;
13731372 }
13741373
0 commit comments