Kill all uses and definitions of tp_print under Objects/. (Others will follow.)

Finally kill intobject.c, which was #ifdef'ed out a long time ago.
This commit is contained in:
Guido van Rossum 2007-08-07 19:51:00 +00:00
parent d474ce8c7a
commit 04dbf3b5ec
11 changed files with 11 additions and 1470 deletions

View file

@ -764,71 +764,6 @@ PyString_AsStringAndSize(register PyObject *obj,
#include "stringlib/partition.h"
static int
string_print(PyStringObject *op, FILE *fp, int flags)
{
Py_ssize_t i;
char c;
int quote;
/* XXX Ought to check for interrupts when writing long strings */
if (! PyString_CheckExact(op)) {
int ret;
/* A str subclass may have its own __str__ method. */
op = (PyStringObject *) PyObject_Str((PyObject *)op);
if (op == NULL)
return -1;
ret = string_print(op, fp, flags);
Py_DECREF(op);
return ret;
}
if (flags & Py_PRINT_RAW) {
char *data = op->ob_sval;
Py_ssize_t size = Py_Size(op);
while (size > INT_MAX) {
/* Very long strings cannot be written atomically.
* But don't write exactly INT_MAX bytes at a time
* to avoid memory aligment issues.
*/
const int chunk_size = INT_MAX & ~0x3FFF;
fwrite(data, 1, chunk_size, fp);
data += chunk_size;
size -= chunk_size;
}
#ifdef __VMS
if (size) fwrite(data, (int)size, 1, fp);
#else
fwrite(data, 1, (int)size, fp);
#endif
return 0;
}
/* figure out which quote to use; single is preferred */
quote = '\'';
if (memchr(op->ob_sval, '\'', Py_Size(op)) &&
!memchr(op->ob_sval, '"', Py_Size(op)))
quote = '"';
fputc(quote, fp);
for (i = 0; i < Py_Size(op); i++) {
c = op->ob_sval[i];
if (c == quote || c == '\\')
fprintf(fp, "\\%c", c);
else if (c == '\t')
fprintf(fp, "\\t");
else if (c == '\n')
fprintf(fp, "\\n");
else if (c == '\r')
fprintf(fp, "\\r");
else if (c < ' ' || c >= 0x7f)
fprintf(fp, "\\x%02x", c & 0xff);
else
fputc(c, fp);
}
fputc(quote, fp);
return 0;
}
PyObject *
PyString_Repr(PyObject *obj, int smartquotes)
{
@ -3983,7 +3918,7 @@ PyTypeObject PyString_Type = {
sizeof(PyStringObject),
sizeof(char),
string_dealloc, /* tp_dealloc */
(printfunc)string_print, /* tp_print */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */