Skip to content

Commit 95b28c7

Browse files
authored
Restore total_bytes to EmptyStreamReader (#10387)
1 parent 8bf5d4d commit 95b28c7

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

CHANGES/10387.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restored the missing ``total_bytes`` attribute to ``EmptyStreamReader`` -- by :user:`bdraco`.

aiohttp/streams.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ class EmptyStreamReader(StreamReader): # lgtm [py/missing-call-to-init]
540540

541541
def __init__(self) -> None:
542542
self._read_eof_chunk = False
543+
self.total_bytes = 0
543544

544545
def __repr__(self) -> str:
545546
return "<%s>" % self.__class__.__name__

tests/test_streams.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,7 @@ async def test_empty_stream_reader() -> None:
11191119
with pytest.raises(asyncio.IncompleteReadError):
11201120
await s.readexactly(10)
11211121
assert s.read_nowait() == b""
1122+
assert s.total_bytes == 0
11221123

11231124

11241125
async def test_empty_stream_reader_iter_chunks() -> None:

0 commit comments

Comments
 (0)