Index: Objects/object.c
===================================================================
--- Objects/object.c	(revision 58158)
+++ Objects/object.c	(working copy)
@@ -279,14 +279,18 @@
 #endif
 	clearerr(fp); /* Clear any previous error condition */
 	if (op == NULL) {
+		Py_BEGIN_ALLOW_THREADS
 		fprintf(fp, "<nil>");
+		Py_END_ALLOW_THREADS
 	}
 	else {
 		if (op->ob_refcnt <= 0)
 			/* XXX(twouters) cast refcount to long until %zd is
 			   universally available */
+			Py_BEGIN_ALLOW_THREADS
 			fprintf(fp, "<refcnt %ld at %p>",
 				(long)op->ob_refcnt, op);
+			Py_END_ALLOW_THREADS
 		else if (Py_Type(op)->tp_print == NULL) {
 			PyObject *s;
 			if (flags & Py_PRINT_RAW)
Index: Objects/intobject.c
===================================================================
--- Objects/intobject.c	(revision 58158)
+++ Objects/intobject.c	(working copy)
@@ -425,7 +425,10 @@
 int_print(PyIntObject *v, FILE *fp, int flags)
      /* flags -- not used but required by interface */
 {
-	fprintf(fp, "%ld", v->ob_ival);
+	long int_val = v->ob_ival;
+	Py_BEGIN_ALLOW_THREADS
+	fprintf(fp, "%ld", int_val);
+	Py_END_ALLOW_THREADS
 	return 0;
 }
 
Index: Objects/listobject.c
===================================================================
--- Objects/listobject.c	(revision 58158)
+++ Objects/listobject.c	(working copy)
@@ -282,19 +282,28 @@
 	if (rc != 0) {
 		if (rc < 0)
 			return rc;
+		Py_BEGIN_ALLOW_THREADS
 		fprintf(fp, "[...]");
+		Py_END_ALLOW_THREADS
 		return 0;
 	}
+	Py_BEGIN_ALLOW_THREADS
 	fprintf(fp, "[");
+	Py_END_ALLOW_THREADS
 	for (i = 0; i < Py_Size(op); i++) {
-		if (i > 0)
+		if (i > 0) {
+			Py_BEGIN_ALLOW_THREADS
 			fprintf(fp, ", ");
+			Py_END_ALLOW_THREADS
+		}
 		if (PyObject_Print(op->ob_item[i], fp, 0) != 0) {
 			Py_ReprLeave((PyObject *)op);
 			return -1;
 		}
 	}
+	Py_BEGIN_ALLOW_THREADS
 	fprintf(fp, "]");
+	Py_END_ALLOW_THREADS
 	Py_ReprLeave((PyObject *)op);
 	return 0;
 }
Index: Objects/fileobject.c
===================================================================
--- Objects/fileobject.c	(revision 58158)
+++ Objects/fileobject.c	(working copy)
@@ -2241,7 +2241,9 @@
 			err_closed();
 			return -1;
 		}
+		Py_BEGIN_ALLOW_THREADS
 		fputs(s, fp);
+		Py_END_ALLOW_THREADS
 		return 0;
 	}
 	else if (!PyErr_Occurred()) {
Index: Objects/stringobject.c
===================================================================
--- Objects/stringobject.c	(revision 58158)
+++ Objects/stringobject.c	(working copy)
@@ -806,6 +806,7 @@
 	if (flags & Py_PRINT_RAW) {
 		char *data = op->ob_sval;
 		Py_ssize_t size = Py_Size(op);
+		Py_BEGIN_ALLOW_THREADS
 		while (size > INT_MAX) {
 			/* Very long strings cannot be written atomically.
 			 * But don't write exactly INT_MAX bytes at a time
@@ -821,6 +822,7 @@
 #else
                 fwrite(data, 1, (int)size, fp);
 #endif
+		Py_END_ALLOW_THREADS
 		return 0;
 	}
 
@@ -830,9 +832,12 @@
 	    !memchr(op->ob_sval, '"', Py_Size(op)))
 		quote = '"';
 
+	Py_BEGIN_ALLOW_THREADS
 	fputc(quote, fp);
+	Py_END_ALLOW_THREADS
 	for (i = 0; i < Py_Size(op); i++) {
 		c = op->ob_sval[i];
+		Py_BEGIN_ALLOW_THREADS
 		if (c == quote || c == '\\')
 			fprintf(fp, "\\%c", c);
                 else if (c == '\t')
@@ -845,8 +850,11 @@
 			fprintf(fp, "\\x%02x", c & 0xff);
 		else
 			fputc(c, fp);
+		Py_END_ALLOW_THREADS
 	}
+	Py_BEGIN_ALLOW_THREADS
 	fputc(quote, fp);
+	Py_END_ALLOW_THREADS
 	return 0;
 }
 
