summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c67
1 files changed, 1 insertions, 66 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 6b03047..7a35974 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -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 */