Issue #23215: Multibyte codecs with custom error handlers that ignores errors

consumed too much memory and raised SystemError or MemoryError.
Original patch by Aleksi Torhamo.
This commit is contained in:
Serhiy Storchaka 2015-02-21 01:19:58 +02:00
parent a3712a9a6c
commit a1543cdcd6
3 changed files with 22 additions and 8 deletions

View file

@ -44,6 +44,13 @@ class Test_MultibyteCodec(unittest.TestCase):
self.assertRaises(IndexError, dec,
b'apple\x92ham\x93spam', 'test.cjktest')
def test_errorcallback_custom_ignore(self):
# Issue #23215: MemoryError with custom error handlers and multibyte codecs
data = 100 * "\udc00"
codecs.register_error("test.ignore", codecs.ignore_errors)
for enc in ALL_CJKENCODINGS:
self.assertEqual(data.encode(enc, "test.ignore"), b'')
def test_codingspec(self):
try:
for enc in ALL_CJKENCODINGS: