Skip to content

Commit c4f4c75

Browse files
committed
gh-141968: Use bytearray.take_bytes() in more I/O paths
1 parent e56f86f commit c4f4c75

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

Lib/zipfile/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def decrypter(data):
759759
c ^= ((k * (k^1)) >> 8) & 0xFF
760760
update_keys(c)
761761
append(c)
762-
return bytes(result)
762+
return result.take_bytes()
763763

764764
return decrypter
765765

Modules/_io/iobase.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,7 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit)
664664
break;
665665
}
666666

667-
result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(buffer),
668-
PyByteArray_GET_SIZE(buffer));
667+
result = PyObject_CallMethodNoArgs(buffer, &_Py_ID(take_bytes));
669668
Py_XDECREF(peek);
670669
Py_DECREF(buffer);
671670
return result;

0 commit comments

Comments
 (0)