summaryrefslogtreecommitdiff
path: root/Doc/extending/newtypes.rst
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2013-03-22 13:49:26 -0700
committerGregory P. Smith <greg@krypto.org>2013-03-22 13:49:26 -0700
commit077f604e22cffbb98e90d5a7b22715e6e5263763 (patch)
treee80385d9fc687f5343e20a8306bd37c00a418611 /Doc/extending/newtypes.rst
parent6a2b959eb25e3572b5743ced85300ed115691259 (diff)
parent176f3bfaa21db21bb9ea9dd16c1803d28492d4d7 (diff)
downloadcpython-077f604e22cffbb98e90d5a7b22715e6e5263763.tar.gz
cleanup references to PyString_ APIs from 2.x in the 3.3 docs.
Diffstat (limited to 'Doc/extending/newtypes.rst')
-rw-r--r--Doc/extending/newtypes.rst19
1 files changed, 9 insertions, 10 deletions
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index 08a70a2af6..835a92e242 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -288,13 +288,13 @@ 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);
return NULL;
@@ -540,9 +540,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;
}
@@ -1005,8 +1005,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
@@ -1025,8 +1025,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);
}
@@ -1342,11 +1342,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;
}