summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2006-03-13 10:24:31 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2006-03-13 10:24:31 (GMT)
commitb0c3bdde45125fef48a4209d33feea365140c255 (patch)
tree32edbf783757a255d8b51e128fe5f40cc1ec8a5c
parentef63e9f345755d216d9b2e5bc817e7a45598e746 (diff)
downloadcpython-b0c3bdde45125fef48a4209d33feea365140c255.zip
cpython-b0c3bdde45125fef48a4209d33feea365140c255.tar.gz
cpython-b0c3bdde45125fef48a4209d33feea365140c255.tar.bz2
Backport from trunk r42989:
Bug #1448490: Fixed a bug that ISO-2022 codecs could not handle SS2 (single-shift 2) escape sequences correctly.
-rw-r--r--Lib/test/test_multibytecodec.py7
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/cjkcodecs/_codecs_iso2022.c2
3 files changed, 11 insertions, 1 deletions
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 @@ 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__":
diff --git a/Misc/NEWS b/Misc/NEWS
index 838d973..6abb881 100644
--- 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.
diff --git a/Modules/cjkcodecs/_codecs_iso2022.c b/Modules/cjkcodecs/_codecs_iso2022.c
index 5cee8ce..ffa9343 100644
--- a/Modules/cjkcodecs/_codecs_iso2022.c
+++ b/Modules/cjkcodecs/_codecs_iso2022.c
@@ -415,7 +415,7 @@ iso2022processg2(const void *config, MultibyteCodec_State *state,
(*inbuf) += 3;
*inleft -= 3;
(*outbuf) += 1;
- *outbuf -= 1;
+ *outleft -= 1;
return 0;
}