[Python-checkins] CVS: python/dist/src/Doc/ext newtypes.tex,1.1,1.2
Barry Warsaw
bwarsaw@users.sourceforge.net
Tue, 28 Aug 2001 18:42:00 -0700
Update of /cvsroot/python/python/dist/src/Doc/ext
In directory usw-pr-cvs1:/tmp/cvs-serv20054
Modified Files:
newtypes.tex
Log Message:
On Fred's suggestion, convert sprintf() examples to use
PyString_FromFormat(). Also fixed one grammar problem, and a few
other mark-up issues. Sample code not checked.
Index: newtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ext/newtypes.tex,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** newtypes.tex 2001/08/20 19:30:29 1.1
--- newtypes.tex 2001/08/29 01:41:58 1.2
***************
*** 498,505 ****
newdatatype_repr(newdatatypeobject * obj)
{
! char buf[4096];
! sprintf(buf, "Repr-ified_newdatatype{{size:%d}}",
obj->obj_UnderlyingDatatypePtr->size);
- return PyString_FromString(buf);
}
\end{verbatim}
--- 498,503 ----
newdatatype_repr(newdatatypeobject * obj)
{
! return PyString_FromFormat("Repr-ified_newdatatype{{size:\%d}}",
obj->obj_UnderlyingDatatypePtr->size);
}
\end{verbatim}
***************
*** 513,517 ****
is, it is called when Python code calls \function{str()} on an
instance of your object. It's implementation is very similar to the
! \member{tp_repr} function, but the resulting string is intended to be
human consumption. It \member{tp_str} is not specified, the
\member{tp_repr} handler is used instead.
--- 511,515 ----
is, it is called when Python code calls \function{str()} on an
instance of your object. It's implementation is very similar to the
! \member{tp_repr} function, but the resulting string is intended for
human consumption. It \member{tp_str} is not specified, the
\member{tp_repr} handler is used instead.
***************
*** 523,533 ****
newdatatype_str(newdatatypeobject * obj)
{
! PyObject *pyString;
! char buf[4096];
! sprintf(buf, "Stringified_newdatatype{{size:%d}}",
obj->obj_UnderlyingDatatypePtr->size
);
- pyString = PyString_FromString(buf);
- return pyString;
}
\end{verbatim}
--- 521,527 ----
newdatatype_str(newdatatypeobject * obj)
{
! return PyString_FromFormat("Stringified_newdatatype{{size:\%d}}",
obj->obj_UnderlyingDatatypePtr->size
);
}
\end{verbatim}
***************
*** 611,617 ****
newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v)
{
! char buf[1024];
! sprintf(buf, "Set attribute not supported for attribute %s", name);
! PyErr_SetString(PyExc_RuntimeError, buf);
return -1;
}
--- 605,609 ----
newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v)
{
! (void)PyErr_Format(PyExc_RuntimeError, "Read-only attribute: \%s", name);
return -1;
}
***************
*** 741,754 ****
char *arg2;
char *arg3;
! char buf[4096];
if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
return NULL;
}
! sprintf(buf,
! "Returning -- value: [%d] arg1: [%s] arg2: [%s] arg3: [%s]\n",
! obj->obj_UnderlyingDatatypePtr->size,
! arg1, arg2, arg3);
! printf(buf);
! return PyString_FromString(buf);
}
\end{verbatim}
--- 733,746 ----
char *arg2;
char *arg3;
!
if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
return NULL;
}
! result = PyString_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;
}
\end{verbatim}