diff options
| author | Hye-Shik Chang <hyeshik@gmail.com> | 2006-10-08 13:56:00 +0000 |
|---|---|---|
| committer | Hye-Shik Chang <hyeshik@gmail.com> | 2006-10-08 13:56:00 +0000 |
| commit | 2d09be9e488828876228bc435d16ee4b90a2ca08 (patch) | |
| tree | 46e623a5fbb10d25c3a4edd3f85000808cb35d5f /Lib | |
| parent | 78754c13ceb37117d94a0dc203ab914c4fd1c8c4 (diff) | |
| download | cpython-git-2d09be9e488828876228bc435d16ee4b90a2ca08.tar.gz | |
Backport from trunk r52223:
Bug #1572832: fix a bug in ISO-2022 codecs which may cause segfault
when encoding non-BMP unicode characters. (Submitted by Ray Chason)
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/test/test_multibytecodec.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py index 9e42f71e79..3fcc8ba81a 100644 --- a/Lib/test/test_multibytecodec.py +++ b/Lib/test/test_multibytecodec.py @@ -7,7 +7,7 @@ from test import test_support from test import test_multibytecodec_support -import unittest, StringIO, codecs +import unittest, StringIO, codecs, sys class Test_StreamWriter(unittest.TestCase): if len(u'\U00012345') == 2: # UCS2 @@ -87,6 +87,16 @@ class Test_ISO2022(unittest.TestCase): e = u'\u3406'.encode(encoding) self.failIf(filter(lambda x: x >= '\x80', e)) + def test_bug1572832(self): + if sys.maxunicode >= 0x10000: + myunichr = unichr + else: + myunichr = lambda x: unichr(0xD7C0+(x>>10)) + unichr(0xDC00+(x&0x3FF)) + + for x in xrange(0x10000, 0x110000): + # Any ISO 2022 codec will cause the segfault + myunichr(x).encode('iso_2022_jp', 'ignore') + def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_StreamWriter)) |
