From 3270fb4be66f2d61de31d2e6315dfdb8ebfb2132 Mon Sep 17 00:00:00 2001 From: xyb Date: Wed, 15 Jan 2014 19:58:11 +0800 Subject: [PATCH] int() test passed --- py/strtonum.c | 14 ++++++-------- tests/basics/tests/int1.py | 2 +- 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)