]> granicus.if.org Git - python/commitdiff
Bug #1448490: Fix a bug that ISO-2022 codecs could not handle
authorHye-Shik Chang <hyeshik@gmail.com>
Mon, 13 Mar 2006 10:20:08 +0000 (10:20 +0000)
committerHye-Shik Chang <hyeshik@gmail.com>
Mon, 13 Mar 2006 10:20:08 +0000 (10:20 +0000)
SS2 (single-shift 2) escape sequences correctly.

Lib/test/test_multibytecodec.py
Misc/NEWS
Modules/cjkcodecs/_codecs_iso2022.c

index acf333e91ea32349051dc836e7cf19249b26e86f..aef7931e037ad88b0d54863243d396fe69f4048d 100644 (file)
@@ -75,9 +75,16 @@ class Test_StreamWriter(unittest.TestCase):
         wr.write('abcd')
         self.assertEqual(s.getvalue(), 'abcd')
 
+class Test_ISO2022(unittest.TestCase):
+    def test_g2(self):
+        iso2022jp2 = '\x1b(B:hu4:unit\x1b.A\x1bNi de famille'
+        uni = u':hu4:unit\xe9 de famille'
+        self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
+
 def test_main():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(Test_StreamWriter))
+    suite.addTest(unittest.makeSuite(Test_ISO2022))
     test_support.run_suite(suite)
 
 if __name__ == "__main__":
index 48c5ae8dd5de33c9384cfe15ef9438d9b83e4709..1c142fb176f6630856f3383a1e2db64b2ec95600 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -279,6 +279,9 @@ Core and builtins
 Extension Modules
 -----------------
 
+- Bug #1448490: Fixed a bug that ISO-2022 codecs could not handle
+  SS2 (single-shift 2) escape sequences correctly.
+
 - The unicodedata module was updated to the 4.1 version of the Unicode
   database. The 3.2 version is still available as unicodedata.db_3_2_0
   for applications that require this specific version (such as IDNA).
index 1e52c34cca169f2090ef447fb3a20595447eb596..8a2ab7eb2f4e5658e9ec1bdccd77004041ef52d1 100644 (file)
@@ -414,7 +414,7 @@ iso2022processg2(const void *config, MultibyteCodec_State *state,
        (*inbuf) += 3;
        *inleft -= 3;
        (*outbuf) += 1;
-       *outbuf -= 1;
+       *outleft -= 1;
        return 0;
 }