]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
issue 3633: Solaris allows fullwidth Unicode digits in isxdigit, so
authorMark Dickinson <dickinsm@gmail.com>
Thu, 21 Aug 2008 21:38:38 +0000 (21:38 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Thu, 21 Aug 2008 21:38:38 +0000 (21:38 +0000)
rewrite float.fromhex to only allow ASCII hex digits on all platforms.
(Tests for this are already present, but the test_float failures
on Solaris hadn't been noticed before.)

Reviewed by Antoine Pitrou.

Objects/floatobject.c

index f70771ee60f3fc0b9032f3bcbd7e5b6d6e448d82..0b067eb37c4b367ea33aa048f2a9cff819713e35 100644 (file)
@@ -1126,7 +1126,6 @@ char_from_hex(int x)
 static int
 hex_from_char(char c) {
        int x;
-       assert(isxdigit(c));
        switch(c) {
        case '0':
                x = 0;
@@ -1355,12 +1354,12 @@ float_fromhex(PyObject *cls, PyObject *arg)
 
        /* coefficient: <integer> [. <fraction>] */
        coeff_start = s;
-       while (isxdigit(*s))
+       while (hex_from_char(*s) >= 0)
                s++;
        s_store = s;
        if (*s == '.') {
                s++;
-               while (isxdigit(*s))
+               while (hex_from_char(*s) >= 0)
                        s++;
                coeff_end = s-1;
        }
@@ -1382,10 +1381,10 @@ float_fromhex(PyObject *cls, PyObject *arg)
                exp_start = s;
                if (*s == '-' || *s == '+')
                        s++;
-               if (!isdigit(*s))
+               if (!('0' <= *s && *s <= '9'))
                        goto parse_error;
                s++;
-               while (isdigit(*s))
+               while ('0' <= *s && *s <= '9')
                        s++;
                exp = strtol(exp_start, NULL, 10);
        }