summaryrefslogtreecommitdiff
path: root/py/parsenum.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/parsenum.c')
-rw-r--r--py/parsenum.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/py/parsenum.c b/py/parsenum.c
index 848a7732d..b90dfaaaf 100644
--- a/py/parsenum.c
+++ b/py/parsenum.c
@@ -291,9 +291,6 @@ parse_start:
if (str == top) {
goto value_error;
}
- } else if (allow_imag && (dig | 0x20) == 'j') {
- real_imag_state |= REAL_IMAG_STATE_HAVE_IMAG;
- break;
} else if (dig == '_') {
continue;
} else {
@@ -327,6 +324,15 @@ parse_start:
}
}
+ if (allow_imag && str < top && (*str | 0x20) == 'j') {
+ if (str == str_val_start) {
+ // Convert "j" to "1j".
+ dec_val = 1;
+ }
+ ++str;
+ real_imag_state |= REAL_IMAG_STATE_HAVE_IMAG;
+ }
+
// negate value if needed
if (dec_neg) {
dec_val = -dec_val;