Skip to content

Commit c60a8f4

Browse files
[PR #10387/95b28c71 backport][3.11] Restore total_bytes to EmptyStreamReader (#10388)
Co-authored-by: J. Nick Koston <[email protected]> fixes #10386
1 parent b752e79 commit c60a8f4

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
@@ -555,6 +555,7 @@ class EmptyStreamReader(StreamReader): # lgtm [py/missing-call-to-init]
555555

556556
def __init__(self) -> None:
557557
self._read_eof_chunk = False
558+
self.total_bytes = 0
558559

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

tests/test_streams.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ async def test_empty_stream_reader() -> None:
11411141
with pytest.raises(asyncio.IncompleteReadError):
11421142
await s.readexactly(10)
11431143
assert s.read_nowait() == b""
1144+
assert s.total_bytes == 0
11441145

11451146

11461147
async def test_empty_stream_reader_iter_chunks() -> None:

0 commit comments

Comments
 (0)