source
stringclasses
1 value
version
stringclasses
1 value
module
stringclasses
43 values
function
stringclasses
307 values
input
stringlengths
3
496
expected
stringlengths
0
40.5k
signature
stringclasses
0 values
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes4
>>> read_bytes4(io.BytesIO(b"\x03\x00\x00\x00abcdef"))
b'abc'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes4
>>> read_bytes4(io.BytesIO(b"\x00\x00\x00\x03abcdef"))
Traceback (most recent call last): ... ValueError: expected 50331648 bytes in a bytes4, but only 6 remain
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes8
>>> import io, struct, sys
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes8
>>> read_bytes8(io.BytesIO(b"\x00\x00\x00\x00\x00\x00\x00\x00abc"))
b''
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes8
>>> read_bytes8(io.BytesIO(b"\x03\x00\x00\x00\x00\x00\x00\x00abcdef"))
b'abc'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes8
>>> bigsize8 = struct.pack("<Q", sys.maxsize//3)
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes8
>>> read_bytes8(io.BytesIO(bigsize8 + b"abcdef")) #doctest: +ELLIPSIS
Traceback (most recent call last): ... ValueError: expected ... bytes in a bytes8, but only 6 remain
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytearray8
>>> import io, struct, sys
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytearray8
>>> read_bytearray8(io.BytesIO(b"\x00\x00\x00\x00\x00\x00\x00\x00abc"))
bytearray(b'')
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytearray8
>>> read_bytearray8(io.BytesIO(b"\x03\x00\x00\x00\x00\x00\x00\x00abcdef"))
bytearray(b'abc')
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytearray8
>>> bigsize8 = struct.pack("<Q", sys.maxsize//3)
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytearray8
>>> read_bytearray8(io.BytesIO(bigsize8 + b"abcdef")) #doctest: +ELLIPSIS
Traceback (most recent call last): ... ValueError: expected ... bytes in a bytearray8, but only 6 remain
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestringnl
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestringnl
>>> read_unicodestringnl(io.BytesIO(b"abc\\uabcd\njunk")) == 'abc\uabcd'
True
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> s = 'abcd\uabcd'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> enc = s.encode('utf-8')
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> enc
b'abcd\xea\xaf\x8d'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> n = bytes([len(enc)]) # little-endian 1-byte length
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> t = read_unicodestring1(io.BytesIO(n + enc + b'junk'))
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> s == t
True
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring1
>>> read_unicodestring1(io.BytesIO(n + enc[:-1]))
Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring1, but only 6 remain
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> s = 'abcd\uabcd'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> enc = s.encode('utf-8')
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> enc
b'abcd\xea\xaf\x8d'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> n = bytes([len(enc), 0, 0, 0]) # little-endian 4-byte length
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> t = read_unicodestring4(io.BytesIO(n + enc + b'junk'))
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> s == t
True
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring4
>>> read_unicodestring4(io.BytesIO(n + enc[:-1]))
Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring4, but only 6 remain
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> s = 'abcd\uabcd'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> enc = s.encode('utf-8')
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> enc
b'abcd\xea\xaf\x8d'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> n = bytes([len(enc)]) + b'\0' * 7 # little-endian 8-byte length
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> t = read_unicodestring8(io.BytesIO(n + enc + b'junk'))
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> s == t
True
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_unicodestring8
>>> read_unicodestring8(io.BytesIO(n + enc[:-1]))
Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring8, but only 6 remain
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_decimalnl_short
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_decimalnl_short
>>> read_decimalnl_short(io.BytesIO(b"1234\n56"))
1234
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_decimalnl_short
>>> read_decimalnl_short(io.BytesIO(b"1234L\n56"))
Traceback (most recent call last): ... ValueError: invalid literal for int() with base 10: b'1234L'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_decimalnl_long
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_decimalnl_long
>>> read_decimalnl_long(io.BytesIO(b"1234L\n56"))
1234
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_decimalnl_long
>>> read_decimalnl_long(io.BytesIO(b"123456789012345678901234L\n6"))
123456789012345678901234
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_floatnl
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_floatnl
>>> read_floatnl(io.BytesIO(b"-1.25\n6"))
-1.25
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_float8
>>> import io, struct
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_float8
>>> raw = struct.pack(">d", -1.25)
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_float8
>>> raw
b'\xbf\xf4\x00\x00\x00\x00\x00\x00'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_float8
>>> read_float8(io.BytesIO(raw + b"\n"))
-1.25
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long1
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x00"))
0
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\xff\x00"))
255
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\xff\x7f"))
32767
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\x00\xff"))
-256
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\x00\x80"))
-32768
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long4
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x00"))
255
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x7f"))
32767
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\xff"))
-256
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\x80"))
-32768
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_long4
>>> read_long1(io.BytesIO(b"\x00\x00\x00\x00"))
0
null
cpython
cfcd524
pickletools
_Example.__init__
>>> import pickle
null
cpython
cfcd524
pickletools
_Example.__init__
>>> x = [1, 2, (3, 4), {b'abc': "def"}]
null
cpython
cfcd524
pickletools
_Example.__init__
>>> pkl0 = pickle.dumps(x, 0)
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pkl0)
0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: I INT 1 8: a APPEND 9: I INT 2 12: a APPEND 13: ( MARK 14: I INT 3 17: I INT 4 20: t TUPLE (MARK at 13) 21: p PUT 1 24: a ...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> pkl1 = pickle.dumps(x, 1)
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pkl1)
0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: K BININT1 1 6: K BININT1 2 8: ( MARK 9: K BININT1 3 11: K BININT1 4 13: t TUPLE (MARK at 8) 14: q BINPUT 1 16: } EMPTY_DICT 17: q ...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> import pickletools
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(pickletools.dis, 0))
0: c GLOBAL 'pickletools dis' 17: p PUT 0 20: . STOP highest protocol among opcodes = 0
null
cpython
cfcd524
pickletools
_Example.__init__
>>> from pickletools import _Example
null
cpython
cfcd524
pickletools
_Example.__init__
>>> x = [_Example(42)] * 2
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(x, 0))
0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: c GLOBAL 'copy_reg _reconstructor' 30: p PUT 1 33: ( MARK 34: c GLOBAL 'pickletools _Example' 56: p PUT 2 59: c GLOBAL '__builtin__ object' 79: p PUT ...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(x, 1))
0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: c GLOBAL 'copy_reg _reconstructor' 29: q BINPUT 1 31: ( MARK 32: c GLOBAL 'pickletools _Example' 54: q BINPUT 2 56: c GLOBAL '__builtin__ object' 76: q ...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> L = []
null
cpython
cfcd524
pickletools
_Example.__init__
>>> T = L,
null
cpython
cfcd524
pickletools
_Example.__init__
>>> L.append(T)
null
cpython
cfcd524
pickletools
_Example.__init__
>>> L[0] is T
True
null
cpython
cfcd524
pickletools
_Example.__init__
>>> T[0] is L
True
null
cpython
cfcd524
pickletools
_Example.__init__
>>> L[0][0] is L
True
null
cpython
cfcd524
pickletools
_Example.__init__
>>> T[0][0] is T
True
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(L, 0))
0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: ( MARK 6: g GET 0 9: t TUPLE (MARK at 5) 10: p PUT 1 13: a APPEND 14: . STOP highest protocol among opcodes = 0
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(L, 1))
0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: h BINGET 0 6: t TUPLE (MARK at 3) 7: q BINPUT 1 9: a APPEND 10: . STOP highest protocol among opcodes = 1 Note that, in the protocol 0 pickle of the recursive tuple, the disassembler has to emulat...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(T, 0))
0: ( MARK 1: ( MARK 2: l LIST (MARK at 1) 3: p PUT 0 6: ( MARK 7: g GET 0 10: t TUPLE (MARK at 6) 11: p PUT 1 14: a APPEND 15: 0 POP 16: 0 POP (MARK at 0) ...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(T, 1))
0: ( MARK 1: ] EMPTY_LIST 2: q BINPUT 0 4: ( MARK 5: h BINGET 0 7: t TUPLE (MARK at 4) 8: q BINPUT 1 10: a APPEND 11: 1 POP_MARK (MARK at 0) 12: h BINGET 1 14: . STOP highest protocol ...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(L, 2))
0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: h BINGET 0 7: \x85 TUPLE1 8: q BINPUT 1 10: a APPEND 11: . STOP highest protocol among opcodes = 2
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(T, 2))
0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: h BINGET 0 7: \x85 TUPLE1 8: q BINPUT 1 10: a APPEND 11: 0 POP 12: h BINGET 1 14: . STOP highest protocol among opcodes = 2 Try protocol 3 with annotations:
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(pickle.dumps(T, 3), annotate=1)
0: \x80 PROTO 3 Protocol version indicator. 2: ] EMPTY_LIST Push an empty list. 3: q BINPUT 0 Store the stack top into the memo. The stack is not popped. 5: h BINGET 0 Read an object from the memo and push it on the stack. 7: \x85 TUPLE1 Build a one-tuple out of the to...
null
cpython
cfcd524
pickletools
_Example.__init__
>>> import pickle
null
cpython
cfcd524
pickletools
_Example.__init__
>>> import io
null
cpython
cfcd524
pickletools
_Example.__init__
>>> f = io.BytesIO()
null
cpython
cfcd524
pickletools
_Example.__init__
>>> p = pickle.Pickler(f, 2)
null
cpython
cfcd524
pickletools
_Example.__init__
>>> x = [1, 2, 3]
null
cpython
cfcd524
pickletools
_Example.__init__
>>> p.dump(x)
null
cpython
cfcd524
pickletools
_Example.__init__
>>> p.dump(x)
null
cpython
cfcd524
pickletools
_Example.__init__
>>> f.seek(0)
0
null
cpython
cfcd524
pickletools
_Example.__init__
>>> memo = {}
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(f, memo=memo)
0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: ( MARK 6: K BININT1 1 8: K BININT1 2 10: K BININT1 3 12: e APPENDS (MARK at 5) 13: . STOP highest protocol among opcodes = 2
null
cpython
cfcd524
pickletools
_Example.__init__
>>> dis(f, memo=memo)
14: \x80 PROTO 2 16: h BINGET 0 18: . STOP highest protocol among opcodes = 2
null
cpython
cfcd524
_pydatetime
date.__repr__
>>> d = date(2010, 1, 1)
null