]> granicus.if.org Git - python/commitdiff
#16336: merge with 3.3.
authorEzio Melotti <ezio.melotti@gmail.com>
Sat, 3 Nov 2012 21:05:18 +0000 (23:05 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Sat, 3 Nov 2012 21:05:18 +0000 (23:05 +0200)
1  2 
Misc/NEWS
Python/codecs.c

diff --cc Misc/NEWS
Simple merge
diff --cc Python/codecs.c
index 5cfb1c90014e26937cfa0a70db8d15898b8ace1f,fd67d1b9e183bc846422b7182f8bdb5c40d7acfd..37ae41b1ca43a44b4bbfd6bf95cf81e3c62f5e1d
@@@ -791,13 -791,13 +791,13 @@@ PyCodec_SurrogatePassErrors(PyObject *e
          /* Try decoding a single surrogate character. If
             there are more, let the codec call us again. */
          p += start;
-         if (strlen(p) > 2 &&
-             ((p[0] & 0xf0) == 0xe0 ||
-              (p[1] & 0xc0) == 0x80 ||
-              (p[2] & 0xc0) == 0x80)) {
+         if (PyBytes_GET_SIZE(object) - start >= 3 &&
+             (p[0] & 0xf0) == 0xe0 &&
+             (p[1] & 0xc0) == 0x80 &&
+             (p[2] & 0xc0) == 0x80) {
              /* it's a three-byte code */
              ch = ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f);
 -            if (ch < 0xd800 || ch > 0xdfff)
 +            if (!Py_UNICODE_IS_SURROGATE(ch))
                  /* it's not a surrogate - fail */
                  ch = 0;
          }