diff --git a/py/parsenum.c b/py/parsenum.c index b1c449c9b8..0be7453ddc 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -81,20 +81,18 @@ mp_obj_t mp_parse_num_integer(const char *restrict str_, size_t len, int base, m for (; str < top; str++) { // get next digit as a value mp_uint_t dig = *str; - if (unichar_isdigit(dig) && (int)dig - '0' < base) { - // 0-9 digit - dig = dig - '0'; - } else if (base == 16) { - dig |= 0x20; - if ('a' <= dig && dig <= 'f') { - // a-f hex digit - dig = dig - 'a' + 10; + if ('0' <= dig && dig <= '9') { + dig -= '0'; + } else { + dig |= 0x20; // make digit lower-case + if ('a' <= dig && dig <= 'z') { + dig -= 'a' - 10; } else { // unknown character break; } - } else { - // unknown character + } + if (dig >= base) { break; }