use Py_CHARMASK
diff --git a/Python/ceval.c b/Python/ceval.c
index 48fce5b..411e7f3 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -753,7 +753,8 @@
/* XXX move into writeobject() ? */
char *s = getstringvalue(v);
int len = getstringsize(v);
- if (len > 0 && isspace(s[len-1]) &&
+ if (len > 0 &&
+ isspace(Py_CHARMASK(s[len-1])) &&
s[len-1] != ' ')
softspace(w, 0);
}
diff --git a/Python/compile.c b/Python/compile.c
index 45bed39..cb25da2 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -608,12 +608,12 @@
*p++ = c;
break;
case 'x':
- if (isxdigit(*s)) {
+ if (isxdigit(Py_CHARMASK(*s))) {
sscanf(s, "%x", &c);
*p++ = c;
do {
s++;
- } while (isxdigit(*s));
+ } while (isxdigit(Py_CHARMASK(*s)));
break;
}
/* FALLTHROUGH */
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index e7c0a57..a646283 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -26,6 +26,14 @@
#include "config.h"
#endif
+/* Convert a possibly signed character to a nonnegative int */
+/* XXX This assumes characters are 8 bits wide */
+#ifdef __CHAR_UNSIGNED__
+#define Py_CHARMASK(c) (c)
+#else
+#define Py_CHARMASK(c) ((c) & 0xff)
+#endif
+
#include "rename2.h"
/* strtol and strtoul, renamed to avoid conflicts */
@@ -70,7 +78,7 @@
}
/* skip leading white space */
- while (*str && isspace(*str))
+ while (*str && isspace(Py_CHARMASK(*str)))
str++;
/* check for leading 0 or 0x for auto-base or base 16 */
@@ -99,7 +107,7 @@
}
/* do the conversion */
- while (c = *str)
+ while (c = Py_CHARMASK(*str))
{
if (isdigit(c) && c - '0' < base)
c -= '0';
@@ -143,7 +151,7 @@
long result;
char sign;
- while (*str && isspace(*str))
+ while (*str && isspace(Py_CHARMASK(*str)))
str++;
sign = *str;