From 6e8085b425a9d02ac3e204651e2c9d8de9a23a85 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 10 May 2014 04:42:56 +0300 Subject: [PATCH] py: Fix base "detection" for int('0', 16). --- py/parsenumbase.c | 4 +++- tests/basics/int1.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) 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))