Skip to content

Commit 6e8085b

Browse files
committed
py: Fix base "detection" for int('0<hexdigit>', 16).
1 parent 7b0f9a7 commit 6e8085b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

py/parsenumbase.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ int mp_parse_num_base(const char *str, uint len, int *base) {
4242
} else if (*base == 0 && (c | 32) == 'b') {
4343
*base = 2;
4444
} else {
45-
*base = 10;
45+
if (*base == 0) {
46+
*base = 10;
47+
}
4648
p -= 2;
4749
}
4850
} else if (*base == 8 && c == '0') {

tests/basics/int1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
print(int('8388607'))
3838
print(int('0x123', 16))
3939
print(int('0X123', 16))
40+
print(int('0A', 16))
4041
print(int('0o123', 8))
4142
print(int('0O123', 8))
4243
print(int('0123', 8))

0 commit comments

Comments
 (0)