Skip to content

Commit d50e7d0

Browse files
committed
support PBytes in int.frombytes
1 parent 715e82d commit d50e7d0

File tree

1 file changed

+8
-0
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints

1 file changed

+8
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.oracle.graal.python.builtins.PythonBuiltins;
4747
import com.oracle.graal.python.builtins.objects.PNone;
4848
import com.oracle.graal.python.builtins.objects.PNotImplemented;
49+
import com.oracle.graal.python.builtins.objects.bytes.PBytes;
4950
import com.oracle.graal.python.nodes.SpecialMethodNames;
5051
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
5152
import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
@@ -1748,6 +1749,13 @@ public Object frombytes(String str, String byteorder, Object[] args, PNone keywo
17481749
byte[] bytes = littleToBig(str.getBytes(), byteorder);
17491750
return factory().createInt(new BigInteger(bytes));
17501751
}
1752+
1753+
@Specialization
1754+
@TruffleBoundary
1755+
public Object fromPBytes(PBytes str, String byteorder, Object[] args, PNone keywordArg) {
1756+
byte[] bytes = littleToBig(str.getInternalByteArray(), byteorder);
1757+
return factory().createInt(new BigInteger(bytes));
1758+
}
17511759
}
17521760

17531761
@Builtin(name = SpecialMethodNames.__BOOL__, fixedNumOfArguments = 1)

0 commit comments

Comments
 (0)