[Python-checkins] r72171 - in python/branches/pep-0383: Lib/test/test_codecs.py Python/codecs.c

martin.v.loewis python-checkins at python.org
Fri May 1 21:43:59 CEST 2009


Author: martin.v.loewis
Date: Fri May  1 21:43:59 2009
New Revision: 72171

Log:
Fix indexing bug in r72164.


Modified:
   python/branches/pep-0383/Lib/test/test_codecs.py
   python/branches/pep-0383/Python/codecs.c

Modified: python/branches/pep-0383/Lib/test/test_codecs.py
==============================================================================
--- python/branches/pep-0383/Lib/test/test_codecs.py	(original)
+++ python/branches/pep-0383/Lib/test/test_codecs.py	Fri May  1 21:43:59 2009
@@ -544,8 +544,10 @@
     def test_surrogates(self):
         self.assertRaises(UnicodeEncodeError, "\ud800".encode, "utf-8")
         self.assertRaises(UnicodeDecodeError, b"\xed\xa0\x80".decode, "utf-8")
-        self.assertEquals("\ud800".encode("utf-8", "surrogates"), b"\xed\xa0\x80")
-        self.assertEquals(b"\xed\xa0\x80".decode("utf-8", "surrogates"), "\ud800")
+        self.assertEquals("abc\ud800def".encode("utf-8", "surrogates"),
+                          b"abc\xed\xa0\x80def")
+        self.assertEquals(b"abc\xed\xa0\x80def".decode("utf-8", "surrogates"),
+                          "abc\ud800def")
         self.assertTrue(codecs.lookup_error("surrogates"))
 
 class UTF7Test(ReadTest):

Modified: python/branches/pep-0383/Python/codecs.c
==============================================================================
--- python/branches/pep-0383/Python/codecs.c	(original)
+++ python/branches/pep-0383/Python/codecs.c	Fri May  1 21:43:59 2009
@@ -801,6 +801,7 @@
 	}
 	/* Try decoding a single surrogate character. If
 	   there are more, let the codec call us again. */
+	p += start;
 	if ((p[0] & 0xf0) == 0xe0 || 
 	    (p[1] & 0xc0) == 0x80 ||
 	    (p[2] & 0xc0) == 0x80) {


More information about the Python-checkins mailing list