Compare commits

...

2 Commits

Author SHA1 Message Date
Miss Islington (bot) cc5eb935c7
bpo-42489: Fix the signature for list.sort() in the tutorial (GH-23538)
(cherry picked from commit d41ec65ab7)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2020-11-28 07:14:23 -08:00
Miss Islington (bot) df6c8bcffe
bpo-34215: Clarify IncompleteReadError message when "expected" is None (GH-21925) (GH-23539)
Co-Authored-By: Tyler Bell <mrbell321@gmail.com>
(cherry picked from commit 8085f742f4)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2020-11-28 17:07:51 +02:00
4 changed files with 10 additions and 5 deletions

View File

@ -78,7 +78,7 @@ objects:
Return the number of times *x* appears in the list.
.. method:: list.sort(key=None, reverse=False)
.. method:: list.sort(*, key=None, reverse=False)
:noindex:
Sort the items of the list in place (the arguments can be used for sort

View File

@ -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

View File

@ -452,12 +452,14 @@ class StreamTests(test_utils.TestCase):
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)

View File

@ -0,0 +1,2 @@
Clarify the error message for :exc:`asyncio.IncompleteReadError` when
``expected`` is ``None``.