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

Skip to content

Commit 42a72ee

Browse files
committed
Merged revisions 65964 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r65964 | mark.dickinson | 2008-08-21 22:38:38 +0100 (Thu, 21 Aug 2008) | 7 lines issue 3633: Solaris allows fullwidth Unicode digits in isxdigit, so 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. ........
1 parent 589b795 commit 42a72ee

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Objects/floatobject.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,6 @@ char_from_hex(int x)
10411041
static int
10421042
hex_from_char(char c) {
10431043
int x;
1044-
assert(isxdigit(c));
10451044
switch(c) {
10461045
case '0':
10471046
x = 0;
@@ -1271,12 +1270,12 @@ float_fromhex(PyObject *cls, PyObject *arg)
12711270

12721271
/* coefficient: <integer> [. <fraction>] */
12731272
coeff_start = s;
1274-
while (isxdigit(*s))
1273+
while (hex_from_char(*s) >= 0)
12751274
s++;
12761275
s_store = s;
12771276
if (*s == '.') {
12781277
s++;
1279-
while (isxdigit(*s))
1278+
while (hex_from_char(*s) >= 0)
12801279
s++;
12811280
coeff_end = s-1;
12821281
}
@@ -1298,10 +1297,10 @@ float_fromhex(PyObject *cls, PyObject *arg)
12981297
exp_start = s;
12991298
if (*s == '-' || *s == '+')
13001299
s++;
1301-
if (!isdigit(*s))
1300+
if (!('0' <= *s && *s <= '9'))
13021301
goto parse_error;
13031302
s++;
1304-
while (isdigit(*s))
1303+
while ('0' <= *s && *s <= '9')
13051304
s++;
13061305
exp = strtol(exp_start, NULL, 10);
13071306
}

0 commit comments

Comments
 (0)