diff --git a/Objects/unicodectype.c b/Objects/unicodectype.c index 106726d7fce..7a330d9052f 100644 --- a/Objects/unicodectype.c +++ b/Objects/unicodectype.c @@ -36,9 +36,12 @@ gettyperecord(Py_UNICODE code) { int index; +#ifdef Py_UNICODE_WIDE if (code >= 0x110000) index = 0; - else { + else +#endif + { index = index1[(code>>SHIFT)]; index = index2[(index<0) { *outp++ = '0' + c/base; c %= base; @@ -655,9 +667,12 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc) return NULL; startp = PyUnicode_AS_UNICODE(object); for (p = startp+start, ressize = 0; p < startp+end; ++p) { +#ifdef Py_UNICODE_WIDE if (*p >= 0x00010000) ressize += 1+1+8; - else if (*p >= 0x100) { + else +#endif + if (*p >= 0x100) { ressize += 1+1+4; } else @@ -670,6 +685,7 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc) p < startp+end; ++p) { Py_UNICODE c = *p; *outp++ = '\\'; +#ifdef Py_UNICODE_WIDE if (c >= 0x00010000) { *outp++ = 'U'; *outp++ = hexdigits[(c>>28)&0xf]; @@ -679,7 +695,9 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc) *outp++ = hexdigits[(c>>12)&0xf]; *outp++ = hexdigits[(c>>8)&0xf]; } - else if (c >= 0x100) { + else +#endif + if (c >= 0x100) { *outp++ = 'u'; *outp++ = hexdigits[(c>>12)&0xf]; *outp++ = hexdigits[(c>>8)&0xf];