From a1543cdcd65d9a2be302be0da0cfb9c53c17f806 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 21 Feb 2015 01:19:58 +0200 Subject: 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. --- Lib/test/test_multibytecodec.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/test/test_multibytecodec.py') diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py index ce267ddeb3..2929f988a8 100644 --- a/Lib/test/test_multibytecodec.py +++ b/Lib/test/test_multibytecodec.py @@ -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: -- cgit v1.2.1