Bug #1448490: Fix a bug that ISO-2022 codecs could not handle
SS2 (single-shift 2) escape sequences correctly.
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index acf333e..aef7931 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -75,9 +75,16 @@
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__":
diff --git a/Misc/NEWS b/Misc/NEWS
index 48c5ae8..1c142fb 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -279,6 +279,9 @@
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).
diff --git a/Modules/cjkcodecs/_codecs_iso2022.c b/Modules/cjkcodecs/_codecs_iso2022.c
index 1e52c34..8a2ab7e 100644
--- a/Modules/cjkcodecs/_codecs_iso2022.c
+++ b/Modules/cjkcodecs/_codecs_iso2022.c
@@ -414,7 +414,7 @@
(*inbuf) += 3;
*inleft -= 3;
(*outbuf) += 1;
- *outbuf -= 1;
+ *outleft -= 1;
return 0;
}