py/parsenum: Allow to parse "infj" and "nanj" as complex numbers.
E.g. complex("nanj") and complex("-infj").
@@ -278,9 +278,6 @@ mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool
if (str == top) {
goto value_error;
}
- } else if (allow_imag && (dig | 0x20) == 'j') {
- imag = true;
- break;
} else if (dig == '_') {
continue;
} else {
@@ -324,6 +321,11 @@ mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool
goto value_error;
}
+ if (allow_imag && str < top && (*str | 0x20) == 'j') {
+ imag = true;
+ str++;
+ }
+
// skip trailing space
for (; str < top && unichar_isspace(*str); str++) {
}
