Skip to content

Commit

Permalink
Restore total_bytes to EmptyStreamReader (#10387)
Browse files Browse the repository at this point in the history
(cherry picked from commit 95b28c7)
  • Loading branch information
bdraco authored and patchback[bot] committed Feb 5, 2025
1 parent 6709f53 commit d514063
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/10387.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restored the missing ``total_bytes`` attribute to ``EmptyStreamReader`` -- by :user:`bdraco`.
1 change: 1 addition & 0 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ class EmptyStreamReader(StreamReader): # lgtm [py/missing-call-to-init]

def __init__(self) -> None:
self._read_eof_chunk = False
self.total_bytes = 0

def __repr__(self) -> str:
return "<%s>" % self.__class__.__name__
Expand Down
1 change: 1 addition & 0 deletions tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ async def test_empty_stream_reader() -> None:
with pytest.raises(asyncio.IncompleteReadError):
await s.readexactly(10)
assert s.read_nowait() == b""
assert s.total_bytes == 0


async def test_empty_stream_reader_iter_chunks() -> None:
Expand Down

0 comments on commit d514063

Please # to comment.