Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 42477:e7fd327e0c19
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.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 07 Aug 2007 19:51:00 +0000 |
| parents | 3fc3cedc49ca |
| children | ac5ce7c43ee7 |
line wrap: on
line diff
--- a/Objects/stringobject.c Tue Aug 07 19:42:11 2007 +0000 +++ b/Objects/stringobject.c Tue Aug 07 19:51:00 2007 +0000 @@ -764,71 +764,6 @@ #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 @@ 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 */
