mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
This fixes an edge case (20206) where if the input ended in a character needing encoding but there was no newline on the string, the last byte of the encoded character would be dropped. The fix is to use a more efficient algorithm, provided by Serhiy Storchaka (5803), that does not have the bug.
This commit is contained in:
parent
2a3d7d1af7
commit
2313e15578
3 changed files with 65 additions and 78 deletions
|
@ -4216,6 +4216,11 @@ class TestQuopri(unittest.TestCase):
|
|||
def test_encode_one_line_eol(self):
|
||||
self._test_encode('hello\n', 'hello\r\n', eol='\r\n')
|
||||
|
||||
def test_encode_one_line_eol_after_non_ascii(self):
|
||||
# issue 20206; see changeset 0cf700464177 for why the encode/decode.
|
||||
self._test_encode('hello\u03c5\n'.encode('utf-8').decode('latin1'),
|
||||
'hello=CF=85\r\n', eol='\r\n')
|
||||
|
||||
def test_encode_one_space(self):
|
||||
self._test_encode(' ', '=20')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue