summaryrefslogtreecommitdiffstats
path: root/Doc/extending
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2013-03-22 20:43:30 (GMT)
committerGregory P. Smith <greg@krypto.org>2013-03-22 20:43:30 (GMT)
commit4b52ae8f971152c2189de1031a7219d33846670d (patch)
tree67b19a3186c548eeca8ee27c6b922c0d6f00e30f /Doc/extending
parent3f885b543256df8acabc39fa9c28f45dfa6e4979 (diff)
downloadcpython-4b52ae8f971152c2189de1031a7219d33846670d.zip
cpython-4b52ae8f971152c2189de1031a7219d33846670d.tar.gz
cpython-4b52ae8f971152c2189de1031a7219d33846670d.tar.bz2
Clean up references to the no longer existing PyString_ APIs in our docs.
Diffstat (limited to 'Doc/extending')
-rw-r--r--Doc/extending/newtypes.rst23
1 files changed, 11 insertions, 12 deletions
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index 3001415..3d68251 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -287,14 +287,14 @@ strings, so we provide a new method::
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);
@@ -449,7 +449,7 @@ concatenation of the first and last names. ::
PyObject *args, *result;
if (format == NULL) {
- format = PyString_FromString("%s %s");
+ format = PyUnicode_FromString("%s %s");
if (format == NULL)
return NULL;
}
@@ -468,7 +468,7 @@ concatenation of the first and last names. ::
if (args == NULL)
return NULL;
- result = PyString_Format(format, args);
+ result = PyUnicode_Format(format, args);
Py_DECREF(args);
return result;
@@ -557,9 +557,9 @@ getting and setting the :attr:`first` attribute::
return -1;
}
- if (! PyString_Check(value)) {
+ if (! PyUnicode_Check(value)) {
PyErr_SetString(PyExc_TypeError,
- "The first attribute value must be a string");
+ "The first attribute value must be a str");
return -1;
}
@@ -1022,8 +1022,8 @@ example::
static PyObject *
newdatatype_repr(newdatatypeobject * obj)
{
- return PyString_FromFormat("Repr-ified_newdatatype{{size:\%d}}",
- obj->obj_UnderlyingDatatypePtr->size);
+ return PyUnicode_FromFormat("Repr-ified_newdatatype{{size:\%d}}",
+ obj->obj_UnderlyingDatatypePtr->size);
}
If no :attr:`tp_repr` handler is specified, the interpreter will supply a
@@ -1042,8 +1042,8 @@ Here is a simple example::
static PyObject *
newdatatype_str(newdatatypeobject * obj)
{
- return PyString_FromFormat("Stringified_newdatatype{{size:\%d}}",
- obj->obj_UnderlyingDatatypePtr->size);
+ return PyUnicode_FromFormat("Stringified_newdatatype{{size:\%d}}",
+ obj->obj_UnderlyingDatatypePtr->size);
}
@@ -1364,11 +1364,10 @@ Here is a desultory example of the implementation of the call function. ::
if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
return NULL;
}
- result = PyString_FromFormat(
+ result = PyUnicode_FromFormat(
"Returning -- value: [\%d] arg1: [\%s] arg2: [\%s] arg3: [\%s]\n",
obj->obj_UnderlyingDatatypePtr->size,
arg1, arg2, arg3);
- printf("\%s", PyString_AS_STRING(result));
return result;
}