Skip to content
Snippets Groups Projects
Unverified Commit 4498e98a authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub
Browse files

bpo-34215: Clarify IncompleteReadError message when "expected" is None (GH-21925) (#23540)


Co-Authored-By: default avatarTyler Bell <mrbell321@gmail.com>
(cherry picked from commit 8085f742)
Co-authored-by: default avatarZackery Spytz <zspytz@gmail.com>
parent 01fcde89
No related branches found
No related tags found
No related merge requests found
......@@ -34,8 +34,9 @@ class IncompleteReadError(EOFError):
- expected: total number of expected bytes (or None if unknown)
"""
def __init__(self, partial, expected):
r_expected = 'undefined' if expected is None else repr(expected)
super().__init__(f'{len(partial)} bytes read on a total of '
f'{expected!r} expected bytes')
f'{r_expected} expected bytes')
self.partial = partial
self.expected = expected
......
......@@ -452,12 +452,14 @@ def test_readuntil_multi_chunks_1(self):
def test_readuntil_eof(self):
stream = asyncio.StreamReader(loop=self.loop)
stream.feed_data(b'some dataAA')
data = b'some dataAA'
stream.feed_data(data)
stream.feed_eof()
with self.assertRaises(asyncio.IncompleteReadError) as cm:
with self.assertRaisesRegex(asyncio.IncompleteReadError,
'undefined expected bytes') as cm:
self.loop.run_until_complete(stream.readuntil(b'AAA'))
self.assertEqual(cm.exception.partial, b'some dataAA')
self.assertEqual(cm.exception.partial, data)
self.assertIsNone(cm.exception.expected)
self.assertEqual(b'', stream._buffer)
......
Clarify the error message for :exc:`asyncio.IncompleteReadError` when
``expected`` is ``None``.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment