summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-08-21 21:38:38 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-08-21 21:38:38 (GMT)
commit5c2bb1a7d43b630efa9e12959d129a56bc7b615e (patch)
tree7c09276496f355b811f62b5f9255ca7ec349384b
parent892429b08b0ee2d252e3624951a7b9b38423f074 (diff)
downloadcpython-5c2bb1a7d43b630efa9e12959d129a56bc7b615e.zip
cpython-5c2bb1a7d43b630efa9e12959d129a56bc7b615e.tar.gz
cpython-5c2bb1a7d43b630efa9e12959d129a56bc7b615e.tar.bz2
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.
-rw-r--r--Objects/floatobject.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index f70771e..0b067eb 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -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);
}