diff -ur Python-3.0a4-orig/Objects/unicodeobject.c Python-3.0a4/Objects/unicodeobject.c --- Python-3.0a4-orig/Objects/unicodeobject.c 2008-04-14 15:14:55.671875000 +0900 +++ Python-3.0a4/Objects/unicodeobject.c 2008-04-14 17:21:20.453125000 +0900 @@ -7512,61 +7512,9 @@ continue; } -#ifdef Py_UNICODE_WIDE - /* Map 21-bit characters to '\U00xxxxxx' */ - else if (ch >= 0x10000) { - *p++ = '\\'; - *p++ = 'U'; - *p++ = hexdigits[(ch >> 28) & 0x0000000F]; - *p++ = hexdigits[(ch >> 24) & 0x0000000F]; - *p++ = hexdigits[(ch >> 20) & 0x0000000F]; - *p++ = hexdigits[(ch >> 16) & 0x0000000F]; - *p++ = hexdigits[(ch >> 12) & 0x0000000F]; - *p++ = hexdigits[(ch >> 8) & 0x0000000F]; - *p++ = hexdigits[(ch >> 4) & 0x0000000F]; - *p++ = hexdigits[ch & 0x0000000F]; - continue; - } -#else - /* Map UTF-16 surrogate pairs to '\U00xxxxxx' */ - else if (ch >= 0xD800 && ch < 0xDC00) { - Py_UNICODE ch2; - Py_UCS4 ucs; - - ch2 = *s++; - size--; - if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) { - ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000; - *p++ = '\\'; - *p++ = 'U'; - *p++ = hexdigits[(ucs >> 28) & 0x0000000F]; - *p++ = hexdigits[(ucs >> 24) & 0x0000000F]; - *p++ = hexdigits[(ucs >> 20) & 0x0000000F]; - *p++ = hexdigits[(ucs >> 16) & 0x0000000F]; - *p++ = hexdigits[(ucs >> 12) & 0x0000000F]; - *p++ = hexdigits[(ucs >> 8) & 0x0000000F]; - *p++ = hexdigits[(ucs >> 4) & 0x0000000F]; - *p++ = hexdigits[ucs & 0x0000000F]; - continue; - } - /* Fall through: isolated surrogates are copied as-is */ - s--; - size++; - } -#endif - - /* Map 16-bit characters to '\uxxxx' */ - if (ch >= 256) { - *p++ = '\\'; - *p++ = 'u'; - *p++ = hexdigits[(ch >> 12) & 0x000F]; - *p++ = hexdigits[(ch >> 8) & 0x000F]; - *p++ = hexdigits[(ch >> 4) & 0x000F]; - *p++ = hexdigits[ch & 0x000F]; - } /* Map special whitespace to '\t', \n', '\r' */ - else if (ch == '\t') { + if (ch == '\t') { *p++ = '\\'; *p++ = 't'; } @@ -7580,7 +7528,7 @@ } /* Map non-printable US ASCII to '\xhh' */ - else if (ch < ' ' || ch >= 0x7F) { + else if (ch < ' ' || ch == 0x7F) { *p++ = '\\'; *p++ = 'x'; *p++ = hexdigits[(ch >> 4) & 0x000F]; @@ -7589,7 +7537,7 @@ /* Copy everything else as-is */ else - *p++ = (char) ch; + *p++ = ch; } /* Add quote */ *p++ = PyUnicode_AS_UNICODE(repr)[0]; diff -ur Python-3.0a4-orig/Python/pythonrun.c Python-3.0a4/Python/pythonrun.c --- Python-3.0a4-orig/Python/pythonrun.c 2008-03-27 08:25:24.000000000 +0900 +++ Python-3.0a4/Python/pythonrun.c 2008-04-14 17:34:35.781250000 +0900 @@ -798,7 +798,7 @@ #endif } else { - if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, NULL, + if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, "backslashreplace", "\n", 0))) { goto error; } @@ -819,7 +819,7 @@ #endif } else { - if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, NULL, + if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, "backslashreplace", "\n", 0))) { goto error; }