mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944)
They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.raw_unicode_escape_decode(). It is True by default to match the former behavior.
This commit is contained in:
parent
d413c50363
commit
39aa98346d
7 changed files with 116 additions and 35 deletions
|
@ -2483,7 +2483,11 @@ class UnicodeEscapeTest(ReadTest, unittest.TestCase):
|
|||
]
|
||||
)
|
||||
|
||||
class RawUnicodeEscapeTest(unittest.TestCase):
|
||||
class RawUnicodeEscapeTest(ReadTest, unittest.TestCase):
|
||||
encoding = "raw-unicode-escape"
|
||||
|
||||
test_lone_surrogates = None
|
||||
|
||||
def test_empty(self):
|
||||
self.assertEqual(codecs.raw_unicode_escape_encode(""), (b"", 0))
|
||||
self.assertEqual(codecs.raw_unicode_escape_decode(b""), ("", 0))
|
||||
|
@ -2532,6 +2536,35 @@ class RawUnicodeEscapeTest(unittest.TestCase):
|
|||
self.assertEqual(decode(br"\U00110000", "ignore"), ("", 10))
|
||||
self.assertEqual(decode(br"\U00110000", "replace"), ("\ufffd", 10))
|
||||
|
||||
def test_partial(self):
|
||||
self.check_partial(
|
||||
"\x00\t\n\r\\\xff\uffff\U00010000",
|
||||
[
|
||||
'\x00',
|
||||
'\x00\t',
|
||||
'\x00\t\n',
|
||||
'\x00\t\n\r',
|
||||
'\x00\t\n\r',
|
||||
'\x00\t\n\r\\\xff',
|
||||
'\x00\t\n\r\\\xff',
|
||||
'\x00\t\n\r\\\xff',
|
||||
'\x00\t\n\r\\\xff',
|
||||
'\x00\t\n\r\\\xff',
|
||||
'\x00\t\n\r\\\xff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff',
|
||||
'\x00\t\n\r\\\xff\uffff\U00010000',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class EscapeEncodeTest(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue