summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/strtonum.c14
-rw-r--r--tests/basics/tests/int1.py2
2 files changed, 7 insertions, 9 deletions
diff --git a/py/strtonum.c b/py/strtonum.c
index 7cc45bcba4..d322f6d8d5 100644
--- a/py/strtonum.c
+++ b/py/strtonum.c
@@ -49,16 +49,14 @@ long strtonum(const char *restrict s, int base) {
p -= 2;
}
} else if (base == 8 && c == '0') {
- if ((c | 32) == 'o') {
- base = 8;
- } else {
- goto value_error;
+ c = *(p++);
+ if ((c | 32) != 'o') {
+ p -= 2;
}
} else if (base == 2 && c == '0') {
- if ((c | 32) == 'b') {
- base = 2;
- } else {
- goto value_error;
+ c = *(p++);
+ if ((c | 32) != 'b') {
+ p -= 2;
}
} else {
if (base == 0) base = 10;
diff --git a/tests/basics/tests/int1.py b/tests/basics/tests/int1.py
index d766216d44..6f3e3f272c 100644
--- a/tests/basics/tests/int1.py
+++ b/tests/basics/tests/int1.py
@@ -38,7 +38,7 @@ def test(value, base):
test(' 1x', 0)
-test(' 1\02 ', 0)
+test(' 1' + chr(2) + ' ', 0)
test('', 0)
test(' ', 0)
test(' \t\t ', 0)