mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-35372: Fix the code page decoder for input > 2 GiB. (GH-10848)
This commit is contained in:
parent
062cbb6772
commit
4013c17911
3 changed files with 24 additions and 5 deletions
|
@ -3190,6 +3190,24 @@ class CodePageTest(unittest.TestCase):
|
|||
codec = codecs.lookup('cp123')
|
||||
self.assertEqual(codec.name, 'mbcs')
|
||||
|
||||
@support.bigmemtest(size=2**31, memuse=7, dry_run=False)
|
||||
def test_large_input(self):
|
||||
# Test input longer than INT_MAX.
|
||||
# Input should contain undecodable bytes before and after
|
||||
# the INT_MAX limit.
|
||||
encoded = (b'01234567' * (2**28-1) +
|
||||
b'\x85\x86\xea\xeb\xec\xef\xfc\xfd\xfe\xff')
|
||||
self.assertEqual(len(encoded), 2**31+2)
|
||||
decoded = codecs.code_page_decode(932, encoded, 'surrogateescape', True)
|
||||
self.assertEqual(decoded[1], len(encoded))
|
||||
del encoded
|
||||
self.assertEqual(len(decoded[0]), decoded[1])
|
||||
self.assertEqual(decoded[0][:10], '0123456701')
|
||||
self.assertEqual(decoded[0][-20:],
|
||||
'6701234567'
|
||||
'\udc85\udc86\udcea\udceb\udcec'
|
||||
'\udcef\udcfc\udcfd\udcfe\udcff')
|
||||
|
||||
|
||||
class ASCIITest(unittest.TestCase):
|
||||
def test_encode(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue