Skip to content

Commit bea4354

Browse files
committed
keep base for string parsing in int constructor
1 parent 91534fa commit bea4354

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_int.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,6 @@ def __int__(self):
312312

313313
assert int(SpecInt1()) == 1
314314
assert int(SpecInt0()) == 0
315+
316+
def test_create_int_from_string():
317+
assert int("5c7920a80f5261a2e5322163c79b71a25a41f414", 16) == 527928385865769069253929759180846776123316630548

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ public abstract static class IntNode extends PythonBuiltinNode {
785785
private Object stringToInt(String num, int base) {
786786
String s = num.replace("_", "");
787787
if ((base >= 2 && base <= 32) || base == 0) {
788-
BigInteger bi = asciiToBigInteger(s, 10, false);
788+
BigInteger bi = asciiToBigInteger(s, base, false);
789789
if (bi.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0 || bi.compareTo(BigInteger.valueOf(Integer.MIN_VALUE)) < 0) {
790790
return bi;
791791
} else {

0 commit comments

Comments
 (0)