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

Skip to content

Commit 30b5c5d

Browse files
committed
Fix SF bug #1072182, problems with signed characters.
Most of these can be backported.
1 parent 5d0ad50 commit 30b5c5d

11 files changed

Lines changed: 16 additions & 14 deletions

File tree

Modules/_hotshot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ get_version_string(void)
13961396
char *buffer;
13971397
int i = 0;
13981398

1399-
while (*rev && !isdigit((int)*rev))
1399+
while (*rev && !isdigit(Py_CHARMASK(*rev)))
14001400
++rev;
14011401
while (rev[i] != ' ' && rev[i] != '\0')
14021402
++i;

Modules/_tkinter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ Tkapp_New(char *screenName, char *baseName, char *className,
636636
}
637637

638638
strcpy(argv0, className);
639-
if (isupper((int)(argv0[0])))
639+
if (isupper(Py_CHARMASK((argv0[0]))))
640640
argv0[0] = tolower(argv0[0]);
641641
Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY);
642642
ckfree(argv0);

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ os2_formatmsg(char *msgbuf, int msglen, char *reason)
463463
if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */
464464
char *lastc = &msgbuf[ strlen(msgbuf)-1 ];
465465

466-
while (lastc > msgbuf && isspace(*lastc))
466+
while (lastc > msgbuf && isspace(Py_CHARMASK(*lastc)))
467467
*lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */
468468
}
469469

Modules/pyexpat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ get_version_string(void)
18031803
char *rev = rcsid;
18041804
int i = 0;
18051805

1806-
while (!isdigit((int)*rev))
1806+
while (!isdigit(Py_CHARMASK(*rev)))
18071807
++rev;
18081808
while (rev[i] != ' ' && rev[i] != '\0')
18091809
++i;

Modules/socketmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,8 @@ set_error(void)
506506
if (strlen(outbuf) > 0) {
507507
/* If non-empty msg, trim CRLF */
508508
char *lastc = &outbuf[ strlen(outbuf)-1 ];
509-
while (lastc > outbuf && isspace(*lastc)) {
509+
while (lastc > outbuf &&
510+
isspace(Py_CHARMASK(*lastc))) {
510511
/* Trim trailing whitespace (CRLF) */
511512
*lastc-- = '\0';
512513
}

Modules/stropmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ strop_atoi(PyObject *self, PyObject *args)
757757
x = (long) PyOS_strtoul(s, &end, base);
758758
else
759759
x = PyOS_strtol(s, &end, base);
760-
if (end == s || !isalnum((int)end[-1]))
760+
if (end == s || !isalnum(Py_CHARMASK(end[-1])))
761761
goto bad;
762762
while (*end && isspace(Py_CHARMASK(*end)))
763763
end++;

Parser/grammar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ translabel(grammar *g, label *lb)
180180
}
181181

182182
if (lb->lb_type == STRING) {
183-
if (isalpha((int)(lb->lb_str[1])) || lb->lb_str[1] == '_') {
183+
if (isalpha(Py_CHARMASK(lb->lb_str[1])) ||
184+
lb->lb_str[1] == '_') {
184185
char *p;
185186
char *src;
186187
char *dest;

Parser/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ get_coding_spec(const char *s, int size)
229229
} while (t[0] == '\x20' || t[0] == '\t');
230230

231231
begin = t;
232-
while (isalnum((int)t[0]) ||
232+
while (isalnum(Py_CHARMASK(t[0])) ||
233233
t[0] == '-' || t[0] == '_' || t[0] == '.')
234234
t++;
235235

Python/ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2879,7 +2879,7 @@ static PyObject *
28792879
parsestr(const char *s, const char *encoding)
28802880
{
28812881
size_t len;
2882-
int quote = *s;
2882+
int quote = Py_CHARMASK(*s);
28832883
int rawmode = 0;
28842884
int need_encoding;
28852885
int unicode = 0;

Python/dynload_aix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ aix_loaderror(const char *pathname)
144144
if (nerr == load_errtab[j].errNo && load_errtab[j].errstr)
145145
ERRBUF_APPEND(load_errtab[j].errstr);
146146
}
147-
while (isdigit(*message[i])) message[i]++ ;
147+
while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ;
148148
ERRBUF_APPEND(message[i]);
149149
ERRBUF_APPEND("\n");
150150
}

0 commit comments

Comments
 (0)