Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 18297:932903c7d054 legacy-trunk
Cosmetic changes to MvL's change to unichr():
- the correct range for the error message is range(0x110000);
- put the 4-byte Unicode-size code inside the same else branch as the
2-byte code, rather generating unreachable code in the 2-byte case.
- Don't hide the 'else' behine the '}'.
(I would prefer that in 4-byte mode, any value should be accepted, but
reasonable people can argue about that, so I'll put that off.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 26 Jun 2001 23:12:25 +0000 |
| parents | ffbb9c918ac0 |
| children | 3ba7a358ce02 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Tue Jun 26 22:59:49 2001 +0000 +++ b/Python/bltinmodule.c Tue Jun 26 23:12:25 2001 +0000 @@ -315,7 +315,7 @@ if (x < 0 || x > 0x10ffff) { PyErr_SetString(PyExc_ValueError, - "unichr() arg not in range(0x10ffff)"); + "unichr() arg not in range(0x110000)"); return NULL; } @@ -323,17 +323,19 @@ /* UCS-2 character */ s[0] = (Py_UNICODE) x; return PyUnicode_FromUnicode(s, 1); - } else { + } + else { #if Py_UNICODE_SIZE == 2 /* UCS-4 character. store as two surrogate characters */ x -= 0x10000L; s[0] = 0xD800 + (Py_UNICODE) (x >> 10); s[1] = 0xDC00 + (Py_UNICODE) (x & 0x03FF); return PyUnicode_FromUnicode(s, 2); +#else + s[0] = (Py_UNICODE)x; + return PyUnicode_FromUnicode(s, 1); #endif } - s[0] = (Py_UNICODE)x; - return PyUnicode_FromUnicode(s, 1); } static char unichr_doc[] =
