diff --git a/Lib/zipfile/__init__.py b/Lib/zipfile/__init__.py index 0accf324c90e3f..c6bd4f8b6fd374 100644 --- a/Lib/zipfile/__init__.py +++ b/Lib/zipfile/__init__.py @@ -759,7 +759,7 @@ def decrypter(data): c ^= ((k * (k^1)) >> 8) & 0xFF update_keys(c) append(c) - return bytes(result) + return result.take_bytes() return decrypter diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 1253f124108bdb..3fd6007a7f1aac 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -664,8 +664,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit) break; } - result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(buffer), - PyByteArray_GET_SIZE(buffer)); + result = PyObject_CallMethodNoArgs(buffer, &_Py_ID(take_bytes)); Py_XDECREF(peek); Py_DECREF(buffer); return result;