diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-12-03 09:15:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-03 09:15:02 (GMT) |
commit | 0f9b6687eb8b26dd804abcc6efd4d6430ae16f24 (patch) | |
tree | ae10652ac48ab1e41fb0b1c9a0f6cbde41b496ea /Lib/test/test_codecs.py | |
parent | f65ede3f8fa08493facf48177540d0ec26e59560 (diff) | |
download | cpython-0f9b6687eb8b26dd804abcc6efd4d6430ae16f24.zip cpython-0f9b6687eb8b26dd804abcc6efd4d6430ae16f24.tar.gz cpython-0f9b6687eb8b26dd804abcc6efd4d6430ae16f24.tar.bz2 |
bpo-35372: Fix the code page decoder for input > 2 GiB. (GH-10848)
(cherry picked from commit 4013c179117754b039957db4730880bf3285919d)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index eb21a39..56485de 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -3191,6 +3191,24 @@ class CodePageTest(unittest.TestCase): finally: _bootlocale.getpreferredencoding = old_getpreferredencoding + @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): |