]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport from trunk r42989:
authorHye-Shik Chang <hyeshik@gmail.com>
Mon, 13 Mar 2006 10:24:31 +0000 (10:24 +0000)
committerHye-Shik Chang <hyeshik@gmail.com>
Mon, 13 Mar 2006 10:24:31 +0000 (10:24 +0000)
Bug #1448490: Fixed a bug that ISO-2022 codecs could not handle
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 838d9735448698a0cb0e469a9ac7837327cd4fc3..6abb881dca91cd159a961e387f99ea95ae80b8cb 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -57,6 +57,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.
+
 - Bug #854823: socketmodule now builds on Sun platforms even when
   INET_ADDRSTRLEN is not defined.
 
index 5cee8ce2c4ec54b951679d87a7bf899750c6ad08..ffa93430ef0892817c4b7f2618bf22d778e46939 100644 (file)
@@ -415,7 +415,7 @@ iso2022processg2(const void *config, MultibyteCodec_State *state,
        (*inbuf) += 3;
        *inleft -= 3;
        (*outbuf) += 1;
-       *outbuf -= 1;
+       *outleft -= 1;
        return 0;
 }