Remove "#ifdef Py_UNICODE_WIDE": Python is now always wide

This commit is contained in:
Victor Stinner 2011-11-22 03:31:20 +01:00
parent 0d3721d986
commit 63ab875cfe
3 changed files with 8 additions and 25 deletions

View File

@ -500,7 +500,7 @@ SRE_COUNT(SRE_STATE* state, SRE_CODE* pattern, Py_ssize_t maxcount)
case SRE_OP_IN: case SRE_OP_IN:
/* repeated set */ /* repeated set */
TRACE(("|%p|%p|COUNT IN\n", pattern, ptr)); TRACE(("|%p|%p|COUNT IN\n", pattern, ptr));
while (ptr < end && while (ptr < end &&
SRE_CHARSET(pattern + 2, SRE_CHARGET(state, ptr, 0))) SRE_CHARSET(pattern + 2, SRE_CHARGET(state, ptr, 0)))
ptr += state->charsize; ptr += state->charsize;
break; break;
@ -1030,7 +1030,7 @@ entrance:
ctx->u.chr = ctx->pattern[ctx->pattern[0]+1]; ctx->u.chr = ctx->pattern[ctx->pattern[0]+1];
for (;;) { for (;;) {
while (ctx->count >= (Py_ssize_t) ctx->pattern[1] && while (ctx->count >= (Py_ssize_t) ctx->pattern[1] &&
(ctx->ptr >= end || (ctx->ptr >= end ||
SRE_CHARGET(state, ctx->ptr, 0) != ctx->u.chr)) { SRE_CHARGET(state, ctx->ptr, 0) != ctx->u.chr)) {
ctx->ptr -= state->charsize; ctx->ptr -= state->charsize;
ctx->count--; ctx->count--;
@ -1302,7 +1302,7 @@ entrance:
if (!p || !e || e < p) if (!p || !e || e < p)
RETURN_FAILURE; RETURN_FAILURE;
while (p < e) { while (p < e) {
if (ctx->ptr >= end || if (ctx->ptr >= end ||
SRE_CHARGET(state, ctx->ptr, 0) != SRE_CHARGET(state, p, 0)) SRE_CHARGET(state, ctx->ptr, 0) != SRE_CHARGET(state, p, 0))
RETURN_FAILURE; RETURN_FAILURE;
p += state->charsize; p += state->charsize;
@ -2664,7 +2664,7 @@ _compile(PyObject* self_, PyObject* args)
if (pattern == Py_None) { if (pattern == Py_None) {
self->logical_charsize = -1; self->logical_charsize = -1;
self->charsize = -1; self->charsize = -1;
} }
else { else {
Py_ssize_t p_length; Py_ssize_t p_length;
if (!getstring(pattern, &p_length, &self->logical_charsize, if (!getstring(pattern, &p_length, &self->logical_charsize,
@ -3021,10 +3021,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
GET_ARG; max = arg; GET_ARG; max = arg;
if (min > max) if (min > max)
FAIL; FAIL;
#ifdef Py_UNICODE_WIDE
if (max > 65535) if (max > 65535)
FAIL; FAIL;
#endif
if (!_validate_inner(code, code+skip-4, groups)) if (!_validate_inner(code, code+skip-4, groups))
FAIL; FAIL;
code += skip-4; code += skip-4;
@ -3042,10 +3040,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
GET_ARG; max = arg; GET_ARG; max = arg;
if (min > max) if (min > max)
FAIL; FAIL;
#ifdef Py_UNICODE_WIDE
if (max > 65535) if (max > 65535)
FAIL; FAIL;
#endif
if (!_validate_inner(code, code+skip-3, groups)) if (!_validate_inner(code, code+skip-3, groups))
FAIL; FAIL;
code += skip-3; code += skip-3;

View File

@ -518,17 +518,10 @@ builtin_chr(PyObject *self, PyObject *args)
return PyUnicode_FromOrdinal(x); return PyUnicode_FromOrdinal(x);
} }
PyDoc_VAR(chr_doc) = PyDoc_STR( PyDoc_STRVAR(chr_doc,
"chr(i) -> Unicode character\n\ "chr(i) -> Unicode character\n\
\n\ \n\
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff." Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.");
)
#ifndef Py_UNICODE_WIDE
PyDoc_STR(
"\nIf 0x10000 <= i, a surrogate pair is returned."
)
#endif
;
static char * static char *

View File

@ -526,23 +526,17 @@ dump_ascii(int fd, PyObject *text)
char c = (char)ch; char c = (char)ch;
write(fd, &c, 1); write(fd, &c, 1);
} }
else if (ch < 256) { else if (ch < 0xff) {
PUTS(fd, "\\x"); PUTS(fd, "\\x");
dump_hexadecimal(2, ch, fd); dump_hexadecimal(2, ch, fd);
} }
else else if (ch < 0xffff) {
#ifdef Py_UNICODE_WIDE
if (ch < 65536)
#endif
{
PUTS(fd, "\\u"); PUTS(fd, "\\u");
dump_hexadecimal(4, ch, fd); dump_hexadecimal(4, ch, fd);
#ifdef Py_UNICODE_WIDE
} }
else { else {
PUTS(fd, "\\U"); PUTS(fd, "\\U");
dump_hexadecimal(8, ch, fd); dump_hexadecimal(8, ch, fd);
#endif
} }
} }
if (truncated) if (truncated)