Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63ab875

Browse files
author
Victor Stinner
committed
Remove "#ifdef Py_UNICODE_WIDE": Python is now always wide
1 parent 0d3721d commit 63ab875

3 files changed

Lines changed: 8 additions & 25 deletions

File tree

Modules/_sre.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ SRE_COUNT(SRE_STATE* state, SRE_CODE* pattern, Py_ssize_t maxcount)
500500
case SRE_OP_IN:
501501
/* repeated set */
502502
TRACE(("|%p|%p|COUNT IN\n", pattern, ptr));
503-
while (ptr < end &&
503+
while (ptr < end &&
504504
SRE_CHARSET(pattern + 2, SRE_CHARGET(state, ptr, 0)))
505505
ptr += state->charsize;
506506
break;
@@ -1030,7 +1030,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern)
10301030
ctx->u.chr = ctx->pattern[ctx->pattern[0]+1];
10311031
for (;;) {
10321032
while (ctx->count >= (Py_ssize_t) ctx->pattern[1] &&
1033-
(ctx->ptr >= end ||
1033+
(ctx->ptr >= end ||
10341034
SRE_CHARGET(state, ctx->ptr, 0) != ctx->u.chr)) {
10351035
ctx->ptr -= state->charsize;
10361036
ctx->count--;
@@ -1302,7 +1302,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern)
13021302
if (!p || !e || e < p)
13031303
RETURN_FAILURE;
13041304
while (p < e) {
1305-
if (ctx->ptr >= end ||
1305+
if (ctx->ptr >= end ||
13061306
SRE_CHARGET(state, ctx->ptr, 0) != SRE_CHARGET(state, p, 0))
13071307
RETURN_FAILURE;
13081308
p += state->charsize;
@@ -2664,7 +2664,7 @@ _compile(PyObject* self_, PyObject* args)
26642664
if (pattern == Py_None) {
26652665
self->logical_charsize = -1;
26662666
self->charsize = -1;
2667-
}
2667+
}
26682668
else {
26692669
Py_ssize_t p_length;
26702670
if (!getstring(pattern, &p_length, &self->logical_charsize,
@@ -3021,10 +3021,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
30213021
GET_ARG; max = arg;
30223022
if (min > max)
30233023
FAIL;
3024-
#ifdef Py_UNICODE_WIDE
30253024
if (max > 65535)
30263025
FAIL;
3027-
#endif
30283026
if (!_validate_inner(code, code+skip-4, groups))
30293027
FAIL;
30303028
code += skip-4;
@@ -3042,10 +3040,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
30423040
GET_ARG; max = arg;
30433041
if (min > max)
30443042
FAIL;
3045-
#ifdef Py_UNICODE_WIDE
30463043
if (max > 65535)
30473044
FAIL;
3048-
#endif
30493045
if (!_validate_inner(code, code+skip-3, groups))
30503046
FAIL;
30513047
code += skip-3;

Python/bltinmodule.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -518,17 +518,10 @@ builtin_chr(PyObject *self, PyObject *args)
518518
return PyUnicode_FromOrdinal(x);
519519
}
520520

521-
PyDoc_VAR(chr_doc) = PyDoc_STR(
521+
PyDoc_STRVAR(chr_doc,
522522
"chr(i) -> Unicode character\n\
523523
\n\
524-
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."
525-
)
526-
#ifndef Py_UNICODE_WIDE
527-
PyDoc_STR(
528-
"\nIf 0x10000 <= i, a surrogate pair is returned."
529-
)
530-
#endif
531-
;
524+
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.");
532525

533526

534527
static char *

Python/traceback.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,23 +526,17 @@ dump_ascii(int fd, PyObject *text)
526526
char c = (char)ch;
527527
write(fd, &c, 1);
528528
}
529-
else if (ch < 256) {
529+
else if (ch < 0xff) {
530530
PUTS(fd, "\\x");
531531
dump_hexadecimal(2, ch, fd);
532532
}
533-
else
534-
#ifdef Py_UNICODE_WIDE
535-
if (ch < 65536)
536-
#endif
537-
{
533+
else if (ch < 0xffff) {
538534
PUTS(fd, "\\u");
539535
dump_hexadecimal(4, ch, fd);
540-
#ifdef Py_UNICODE_WIDE
541536
}
542537
else {
543538
PUTS(fd, "\\U");
544539
dump_hexadecimal(8, ch, fd);
545-
#endif
546540
}
547541
}
548542
if (truncated)

0 commit comments

Comments
 (0)