summaryrefslogtreecommitdiff
path: root/tests/basics/int_longint_bytes.py
blob: 31510d75ad536493bad8400813a0f1b8dec3f02d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Skip if long ints are not supported.
try:
    # We have to use variables because 1 << 40 causes an exception on parse and
    # cannot be caught.
    x = 40
    x = 1 << x
except OverflowError:
    print("SKIP")
    import sys
    sys.exit(1)

print((2**64).to_bytes(9, "little"))
print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little"))
print(int.from_bytes(b"\x01\0\0\0\0\0\0\0", "little"))
print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little"))