Skip to content

Commit 81fd559

Browse files
committed
[GR-11736] Keep base for string parsing in int constructor.
PullRequest: graalpython/195
2 parents 5c7920a + bea4354 commit 81fd559

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
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 {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ private void checkFunctionResult(String name, boolean isNull) {
593593
private boolean isNull(TruffleObject result) {
594594
if (isNullNode == null) {
595595
CompilerDirectives.transferToInterpreterAndInvalidate();
596-
isNullNode = Message.IS_NULL.createNode();
596+
isNullNode = insert(Message.IS_NULL.createNode());
597597
}
598598
return ForeignAccess.sendIsNull(isNullNode, result);
599599
}

0 commit comments

Comments
 (0)