[Python-checkins] commit of r41768 - in python/trunk: Modules/_hotshot.c Modules/_tkinter.c Modules/posixmodule.c Modules/pyexpat.c Modules/socketmodule.c Modules/stropmodule.c Parser/grammar.c Parser/tokenizer.c Python/ast.c Python/dynload_aix.c Python/getargs.c

neal.norwitz python-checkins at python.org
Mon Dec 19 07:05:31 CET 2005


Author: neal.norwitz
Date: Mon Dec 19 07:05:18 2005
New Revision: 41768

Modified:
   python/trunk/Modules/_hotshot.c
   python/trunk/Modules/_tkinter.c
   python/trunk/Modules/posixmodule.c
   python/trunk/Modules/pyexpat.c
   python/trunk/Modules/socketmodule.c
   python/trunk/Modules/stropmodule.c
   python/trunk/Parser/grammar.c
   python/trunk/Parser/tokenizer.c
   python/trunk/Python/ast.c
   python/trunk/Python/dynload_aix.c
   python/trunk/Python/getargs.c
Log:
Fix SF bug #1072182, problems with signed characters.

Most of these can be backported.


Modified: python/trunk/Modules/_hotshot.c
==============================================================================
--- python/trunk/Modules/_hotshot.c	(original)
+++ python/trunk/Modules/_hotshot.c	Mon Dec 19 07:05:18 2005
@@ -1396,7 +1396,7 @@
     char *buffer;
     int i = 0;
 
-    while (*rev && !isdigit((int)*rev))
+    while (*rev && !isdigit(Py_CHARMASK(*rev)))
         ++rev;
     while (rev[i] != ' ' && rev[i] != '\0')
         ++i;

Modified: python/trunk/Modules/_tkinter.c
==============================================================================
--- python/trunk/Modules/_tkinter.c	(original)
+++ python/trunk/Modules/_tkinter.c	Mon Dec 19 07:05:18 2005
@@ -636,7 +636,7 @@
 	}
 
 	strcpy(argv0, className);
-	if (isupper((int)(argv0[0])))
+	if (isupper(Py_CHARMASK((argv0[0]))))
 		argv0[0] = tolower(argv0[0]);
 	Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY);
 	ckfree(argv0);

Modified: python/trunk/Modules/posixmodule.c
==============================================================================
--- python/trunk/Modules/posixmodule.c	(original)
+++ python/trunk/Modules/posixmodule.c	Mon Dec 19 07:05:18 2005
@@ -463,7 +463,7 @@
     if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */
         char *lastc = &msgbuf[ strlen(msgbuf)-1 ];
 
-        while (lastc > msgbuf && isspace(*lastc))
+        while (lastc > msgbuf && isspace(Py_CHARMASK(*lastc)))
             *lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */
     }
 

Modified: python/trunk/Modules/pyexpat.c
==============================================================================
--- python/trunk/Modules/pyexpat.c	(original)
+++ python/trunk/Modules/pyexpat.c	Mon Dec 19 07:05:18 2005
@@ -1803,7 +1803,7 @@
     char *rev = rcsid;
     int i = 0;
 
-    while (!isdigit((int)*rev))
+    while (!isdigit(Py_CHARMASK(*rev)))
         ++rev;
     while (rev[i] != ' ' && rev[i] != '\0')
         ++i;

Modified: python/trunk/Modules/socketmodule.c
==============================================================================
--- python/trunk/Modules/socketmodule.c	(original)
+++ python/trunk/Modules/socketmodule.c	Mon Dec 19 07:05:18 2005
@@ -506,7 +506,8 @@
 			if (strlen(outbuf) > 0) {
 				/* If non-empty msg, trim CRLF */
 				char *lastc = &outbuf[ strlen(outbuf)-1 ];
-				while (lastc > outbuf && isspace(*lastc)) {
+				while (lastc > outbuf &&
+				       isspace(Py_CHARMASK(*lastc))) {
 					/* Trim trailing whitespace (CRLF) */
 					*lastc-- = '\0';
 				}

Modified: python/trunk/Modules/stropmodule.c
==============================================================================
--- python/trunk/Modules/stropmodule.c	(original)
+++ python/trunk/Modules/stropmodule.c	Mon Dec 19 07:05:18 2005
@@ -757,7 +757,7 @@
 		x = (long) PyOS_strtoul(s, &end, base);
 	else
 		x = PyOS_strtol(s, &end, base);
-	if (end == s || !isalnum((int)end[-1]))
+	if (end == s || !isalnum(Py_CHARMASK(end[-1])))
 		goto bad;
 	while (*end && isspace(Py_CHARMASK(*end)))
 		end++;

Modified: python/trunk/Parser/grammar.c
==============================================================================
--- python/trunk/Parser/grammar.c	(original)
+++ python/trunk/Parser/grammar.c	Mon Dec 19 07:05:18 2005
@@ -180,7 +180,8 @@
 	}
 	
 	if (lb->lb_type == STRING) {
-		if (isalpha((int)(lb->lb_str[1])) || lb->lb_str[1] == '_') {
+		if (isalpha(Py_CHARMASK(lb->lb_str[1])) ||
+		    lb->lb_str[1] == '_') {
 			char *p;
 			char *src;
 			char *dest;

Modified: python/trunk/Parser/tokenizer.c
==============================================================================
--- python/trunk/Parser/tokenizer.c	(original)
+++ python/trunk/Parser/tokenizer.c	Mon Dec 19 07:05:18 2005
@@ -229,7 +229,7 @@
 			} while (t[0] == '\x20' || t[0] == '\t');
 
 			begin = t;
-			while (isalnum((int)t[0]) ||
+			while (isalnum(Py_CHARMASK(t[0])) ||
 			       t[0] == '-' || t[0] == '_' || t[0] == '.')
 				t++;
 

Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Mon Dec 19 07:05:18 2005
@@ -2879,7 +2879,7 @@
 parsestr(const char *s, const char *encoding)
 {
 	size_t len;
-	int quote = *s;
+	int quote = Py_CHARMASK(*s);
 	int rawmode = 0;
 	int need_encoding;
 	int unicode = 0;

Modified: python/trunk/Python/dynload_aix.c
==============================================================================
--- python/trunk/Python/dynload_aix.c	(original)
+++ python/trunk/Python/dynload_aix.c	Mon Dec 19 07:05:18 2005
@@ -144,7 +144,7 @@
 		    if (nerr == load_errtab[j].errNo && load_errtab[j].errstr)
 			ERRBUF_APPEND(load_errtab[j].errstr);
 		}
-		while (isdigit(*message[i])) message[i]++ ; 
+		while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ; 
 		ERRBUF_APPEND(message[i]);
 		ERRBUF_APPEND("\n");
 	}

Modified: python/trunk/Python/getargs.c
==============================================================================
--- python/trunk/Python/getargs.c	(original)
+++ python/trunk/Python/getargs.c	Mon Dec 19 07:05:18 2005
@@ -166,7 +166,7 @@
 			if (level == 0) {
 				if (c == 'O')
 					max++;
-				else if (isalpha(c)) {
+				else if (isalpha(Py_CHARMASK(c))) {
 					if (c != 'e') /* skip encoded */
 						max++;
 				} else if (c == '|')
@@ -255,7 +255,7 @@
 		}
 	}
 
-	if (*format != '\0' && !isalpha((int)(*format)) &&
+	if (*format != '\0' && !isalpha(Py_CHARMASK((*format))) &&
 	    *format != '(' &&
 	    *format != '|' && *format != ':' && *format != ';') {
 		PyErr_Format(PyExc_SystemError,
@@ -347,7 +347,7 @@
 		}
 		else if (c == ':' || c == ';' || c == '\0')
 			break;
-		else if (level == 0 && isalpha(c))
+		else if (level == 0 && isalpha(Py_CHARMASK(c)))
 			n++;
 	}
 	
@@ -1223,7 +1223,7 @@
 	min = -1;
 	max = 0;
 	while ((i = *format++) != '\0') {
-		if (isalpha(i) && i != 'e') {
+		if (isalpha(Py_CHARMASK(i)) && i != 'e') {
 			max++;
 			if (*p == NULL) {
 				PyErr_SetString(PyExc_RuntimeError,


More information about the Python-checkins mailing list