Skip to content

Commit 735e1ac

Browse files
committed
fix(multipart): ensure BodyPartReader.read() returns bytes not bytearray
The read() method accumulated data in a bytearray but returned it directly, violating the documented return type annotation (bytes). This caused TypeError when passing the result to json.dumps or other APIs that expect bytes rather than bytearray.
1 parent b0601d6 commit 735e1ac

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

aiohttp/multipart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ async def read(self, *, decode: bool = False) -> bytes:
322322
decoded_data.extend(d)
323323
if len(decoded_data) > self._client_max_size:
324324
raise self._max_size_error_cls(self._client_max_size)
325-
return decoded_data
326-
return data
325+
return bytes(decoded_data)
326+
return bytes(data)
327327

328328
async def read_chunk(self, size: int = chunk_size) -> bytes:
329329
"""Reads body part content chunk of the specified size.

0 commit comments

Comments
 (0)