Skip to content

Commit c0ff30a

Browse files
committed
Add missing TruffleBoundary.
1 parent 70de9ff commit c0ff30a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,20 +1000,20 @@ public Object createInt(PythonClass cls, String arg, @SuppressWarnings("unused")
10001000
@Specialization(guards = "isPrimitiveInt(cls)", rewriteOn = NumberFormatException.class)
10011001
@TruffleBoundary
10021002
int parseInt(Object cls, PIBytesLike arg, int keywordArg) throws NumberFormatException {
1003-
return parseInt(cls, new String(getByteArray(arg)), keywordArg);
1003+
return parseInt(cls, toString(arg), keywordArg);
10041004
}
10051005

10061006
@Specialization(guards = "isPrimitiveInt(cls)", rewriteOn = NumberFormatException.class)
10071007
@TruffleBoundary
10081008
long parseLong(Object cls, PIBytesLike arg, int keywordArg) throws NumberFormatException {
1009-
return parseLong(cls, new String(getByteArray(arg)), keywordArg);
1009+
return parseLong(cls, toString(arg), keywordArg);
10101010
}
10111011

10121012
@Specialization
10131013
Object parseBytesError(PythonClass cls, PIBytesLike arg, int base,
10141014
@Cached("create()") BranchProfile errorProfile) {
10151015
try {
1016-
return parsePInt(cls, new String(getByteArray(arg)), base);
1016+
return parsePInt(cls, toString(arg), base);
10171017
} catch (NumberFormatException e) {
10181018
errorProfile.enter();
10191019
throw raise(ValueError, "invalid literal for int() with base %s: %s", base, arg);
@@ -1144,12 +1144,17 @@ protected static boolean isHandledType(Object obj) {
11441144
return PGuards.isInteger(obj) || obj instanceof Double || obj instanceof Boolean || PGuards.isString(obj) || PGuards.isBytes(obj);
11451145
}
11461146

1147-
private byte[] getByteArray(PIBytesLike pByteArray) {
1147+
private String toString(PIBytesLike pByteArray) {
11481148
if (toByteArrayNode == null) {
11491149
CompilerDirectives.transferToInterpreterAndInvalidate();
11501150
toByteArrayNode = insert(BytesNodes.ToBytesNode.create());
11511151
}
1152-
return toByteArrayNode.execute(pByteArray);
1152+
return toString(toByteArrayNode.execute(pByteArray));
1153+
}
1154+
1155+
@TruffleBoundary
1156+
private static String toString(byte[] barr) {
1157+
return new String(barr);
11531158
}
11541159

11551160
}

0 commit comments

Comments
 (0)