diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-10 04:42:56 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-10 04:45:15 +0300 |
commit | 6e8085b425a9d02ac3e204651e2c9d8de9a23a85 (patch) | |
tree | 40c6b145bf2b01b574940d1cb1dfe046d792d3de | |
parent | 7b0f9a7d9b8a119093ea31c78368b5314bbf23a7 (diff) | |
download | micropython-6e8085b425a9d02ac3e204651e2c9d8de9a23a85.tar.gz micropython-6e8085b425a9d02ac3e204651e2c9d8de9a23a85.zip |
py: Fix base "detection" for int('0<hexdigit>', 16).
-rw-r--r-- | py/parsenumbase.c | 4 | ||||
-rw-r--r-- | tests/basics/int1.py | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/py/parsenumbase.c b/py/parsenumbase.c index 819b6655ba..0057e467e5 100644 --- a/py/parsenumbase.c +++ b/py/parsenumbase.c @@ -42,7 +42,9 @@ int mp_parse_num_base(const char *str, uint len, int *base) { } else if (*base == 0 && (c | 32) == 'b') { *base = 2; } else { - *base = 10; + if (*base == 0) { + *base = 10; + } p -= 2; } } else if (*base == 8 && c == '0') { diff --git a/tests/basics/int1.py b/tests/basics/int1.py index 4ce0f9e70c..2daef9bf0e 100644 --- a/tests/basics/int1.py +++ b/tests/basics/int1.py @@ -37,6 +37,7 @@ print(int('0o123', 0)) print(int('8388607')) print(int('0x123', 16)) print(int('0X123', 16)) +print(int('0A', 16)) print(int('0o123', 8)) print(int('0O123', 8)) print(int('0123', 8)) |