Rewrite IOBase.readall to avoid costly string resizes, and plug a leak
diff --git a/Modules/_bufferedio.c b/Modules/_bufferedio.c
index 01171cd..9960dba 100644
--- a/Modules/_bufferedio.c
+++ b/Modules/_bufferedio.c
@@ -1144,7 +1144,6 @@
PyObject *data, *res = NULL;
Py_ssize_t current_size, remaining, written;
char *out;
- static PyObject *sep = NULL;
/* Special case for when the number of bytes to read is unspecified. */
if (n == -1) {
@@ -1201,15 +1200,7 @@
return data;
}
else {
- if (sep == NULL) {
- sep = PyBytes_FromStringAndSize(NULL, 0);
- if (sep == NULL) {
- Py_DECREF(data);
- Py_DECREF(chunks);
- return NULL;
- }
- }
- res =_PyBytes_Join(sep, chunks);
+ res = _PyBytes_Join(_PyIO_empty_bytes, chunks);
Py_DECREF(data);
Py_DECREF(chunks);
return res;