source
stringclasses
2 values
version
stringclasses
2 values
module
stringclasses
53 values
function
stringclasses
318 values
input
stringlengths
3
496
expected
stringlengths
0
876
signature
stringclasses
41 values
cpython
3.10
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
3.10
pickletools
ArgumentDescriptor.read_decimalnl_long
>>> import io
null
cpython
3.10
pickletools
ArgumentDescriptor.read_decimalnl_long
>>> read_decimalnl_long(io.BytesIO(b"1234L\n56"))
1234
null
cpython
3.10
pickletools
ArgumentDescriptor.read_decimalnl_long
>>> read_decimalnl_long(io.BytesIO(b"123456789012345678901234L\n6"))
123456789012345678901234
null
cpython
3.10
pickletools
ArgumentDescriptor.read_floatnl
>>> import io
null
cpython
3.10
pickletools
ArgumentDescriptor.read_floatnl
>>> read_floatnl(io.BytesIO(b"-1.25\n6"))
-1.25
null
cpython
3.10
pickletools
ArgumentDescriptor.read_float8
>>> import io, struct
null
cpython
3.10
pickletools
ArgumentDescriptor.read_float8
>>> raw = struct.pack(">d", -1.25)
null
cpython
3.10
pickletools
ArgumentDescriptor.read_float8
>>> raw
b'\xbf\xf4\x00\x00\x00\x00\x00\x00'
null
cpython
3.10
pickletools
ArgumentDescriptor.read_float8
>>> read_float8(io.BytesIO(raw + b"\n"))
-1.25
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long1
>>> import io
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x00"))
0
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\xff\x00"))
255
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\xff\x7f"))
32767
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\x00\xff"))
-256
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long1
>>> read_long1(io.BytesIO(b"\x02\x00\x80"))
-32768
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long4
>>> import io
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x00"))
255
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x7f"))
32767
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\xff"))
-256
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long4
>>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\x80"))
-32768
null
cpython
3.10
pickletools
ArgumentDescriptor.read_long4
>>> read_long1(io.BytesIO(b"\x00\x00\x00\x00"))
0
null
cpython
3.10
pickletools
_Example.__init__
>>> import pickle
null
cpython
3.10
pickletools
_Example.__init__
>>> x = [1, 2, (3, 4), {b'abc': "def"}]
null
cpython
3.10
pickletools
_Example.__init__
>>> pkl0 = pickle.dumps(x, 0)
null
cpython
3.10
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 APPEND 25: ( MARK 26: d DICT (MARK at 25) 27: p PUT 2 30: c GLOBAL '_codecs encode' 46: p PUT 3 49: ( MARK 50: V UNICODE 'abc' 55: p PUT 4 58: V UNICODE 'latin1' 66: p PUT 5 69: t TUPLE (MARK at 49) 70: p PUT 6 73: R REDUCE 74: p PUT 7 77: V UNICODE 'def' 82: p PUT 8 85: s SETITEM 86: a APPEND 87: . STOP highest protocol among opcodes = 0
null
cpython
3.10
pickletools
_Example.__init__
>>> pkl1 = pickle.dumps(x, 1)
null
cpython
3.10
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 BINPUT 2 19: c GLOBAL '_codecs encode' 35: q BINPUT 3 37: ( MARK 38: X BINUNICODE 'abc' 46: q BINPUT 4 48: X BINUNICODE 'latin1' 59: q BINPUT 5 61: t TUPLE (MARK at 37) 62: q BINPUT 6 64: R REDUCE 65: q BINPUT 7 67: X BINUNICODE 'def' 75: q BINPUT 8 77: s SETITEM 78: e APPENDS (MARK at 3) 79: . STOP highest protocol among opcodes = 1
null
cpython
3.10
pickletools
_Example.__init__
>>> import pickletools
null
cpython
3.10
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
3.10
pickletools
_Example.__init__
>>> from pickletools import _Example
null
cpython
3.10
pickletools
_Example.__init__
>>> x = [_Example(42)] * 2
null
cpython
3.10
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 3 82: N NONE 83: t TUPLE (MARK at 33) 84: p PUT 4 87: R REDUCE 88: p PUT 5 91: ( MARK 92: d DICT (MARK at 91) 93: p PUT 6 96: V UNICODE 'value' 103: p PUT 7 106: I INT 42 110: s SETITEM 111: b BUILD 112: a APPEND 113: g GET 5 116: a APPEND 117: . STOP highest protocol among opcodes = 0
null
cpython
3.10
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 BINPUT 3 78: N NONE 79: t TUPLE (MARK at 31) 80: q BINPUT 4 82: R REDUCE 83: q BINPUT 5 85: } EMPTY_DICT 86: q BINPUT 6 88: X BINUNICODE 'value' 98: q BINPUT 7 100: K BININT1 42 102: s SETITEM 103: b BUILD 104: h BINGET 5 106: e APPENDS (MARK at 3) 107: . STOP highest protocol among opcodes = 1
null
cpython
3.10
pickletools
_Example.__init__
>>> L = []
null
cpython
3.10
pickletools
_Example.__init__
>>> T = L,
null
cpython
3.10
pickletools
_Example.__init__
>>> L.append(T)
null
cpython
3.10
pickletools
_Example.__init__
>>> L[0] is T
True
null
cpython
3.10
pickletools
_Example.__init__
>>> T[0] is L
True
null
cpython
3.10
pickletools
_Example.__init__
>>> L[0][0] is L
True
null
cpython
3.10
pickletools
_Example.__init__
>>> T[0][0] is T
True
null
cpython
3.10
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
3.10
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
null
cpython
3.10
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) 17: g GET 1 20: . STOP highest protocol among opcodes = 0
null
cpython
3.10
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 among opcodes = 1
null
cpython
3.10
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
3.10
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
null
cpython
3.10
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 topmost item on the stack. 8: q BINPUT 1 Store the stack top into the memo. The stack is not popped. 10: a APPEND Append an object to a list. 11: 0 POP Discard the top stack item, shrinking the stack by one item. 12: h BINGET 1 Read an object from the memo and push it on the stack. 14: . STOP Stop the unpickling machine. highest protocol among opcodes = 2
null
cpython
3.10
pickletools
_Example.__init__
>>> import pickle
null
cpython
3.10
pickletools
_Example.__init__
>>> import io
null
cpython
3.10
pickletools
_Example.__init__
>>> f = io.BytesIO()
null
cpython
3.10
pickletools
_Example.__init__
>>> p = pickle.Pickler(f, 2)
null
cpython
3.10
pickletools
_Example.__init__
>>> x = [1, 2, 3]
null
cpython
3.10
pickletools
_Example.__init__
>>> p.dump(x)
null
cpython
3.10
pickletools
_Example.__init__
>>> p.dump(x)
null
cpython
3.10
pickletools
_Example.__init__
>>> f.seek(0)
0
null
cpython
3.10
pickletools
_Example.__init__
>>> memo = {}
null
cpython
3.10
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
3.10
pickletools
_Example.__init__
>>> dis(f, memo=memo)
14: \x80 PROTO 2 16: h BINGET 0 18: . STOP highest protocol among opcodes = 2
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> import time
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> import pydoc
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> def my_url_handler(url, content_type): ... text = 'the URL sent was: (%s, %s)' % (url, content_type) ... return text
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> port = 0
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> serverthread = pydoc._start_server(my_url_handler, port)
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> if serverthread.serving: ... import webbrowser
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> starttime = time.monotonic()
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> timeout = 1 #seconds
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> while serverthread.serving: ... time.sleep(.01) ... if serverthread.serving and time.monotonic() - starttime > timeout: ... serverthread.stop() ... break
null
cpython
3.10
pydoc
ModuleScanner._start_server
>>> print(serverthread.error)
None
null
cpython
3.10
datetime
date.__repr__
>>> dt = datetime(2010, 1, 1)
null
cpython
3.10
datetime
date.__repr__
>>> repr(dt)
'datetime.datetime(2010, 1, 1, 0, 0)'
null
cpython
3.10
datetime
date.__repr__
>>> dt = datetime(2010, 1, 1, tzinfo=timezone.utc)
null
cpython
3.10
datetime
date.__repr__
>>> repr(dt)
'datetime.datetime(2010, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)'
null
cpython
3.10
datetime
timezone.__repr__
>>> tz = timezone.utc
null
cpython
3.10
datetime
timezone.__repr__
>>> repr(tz)
'datetime.timezone.utc'
null
cpython
3.10
datetime
timezone.__repr__
>>> tz = timezone(timedelta(hours=-5), 'EST')
null
cpython
3.10
datetime
timezone.__repr__
>>> repr(tz)
"datetime.timezone(datetime.timedelta(-1, 68400), 'EST')"
null
cpython
3.10
pdb
__module__
>>> import pdb
null
cpython
3.10
pdb
__module__
>>> pdb.run('<a statement>')
null
cpython
3.10
pdb
__module__
>>> <a statement>
<exception traceback>
null
cpython
3.10
pdb
__module__
>>> import pdb
null
cpython
3.10
pdb
__module__
>>> pdb.pm()
null
cpython
3.10
unittest.mock
NonCallableMock.configure_mock
>>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
null
cpython
3.10
unittest.mock
NonCallableMock.configure_mock
>>> mock.configure_mock(**attrs)
null
cpython
3.10
unittest.mock
AsyncMock
>>> mock = AsyncMock()
null
cpython
3.10
unittest.mock
AsyncMock
>>> iscoroutinefunction(mock)
True
null
cpython
3.10
unittest.mock
AsyncMock
>>> inspect.isawaitable(mock())
True
null
cpython
3.10
ipaddress
NetmaskValueError.summarize_address_range
>>> list(summarize_address_range(IPv4Address('192.0.2.0'), ... IPv4Address('192.0.2.130'))) ... #doctest: +NORMALIZE_WHITESPACE
[IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/31'), IPv4Network('192.0.2.130/32')]
null
cpython
3.10
ipaddress
_IPAddressBase.reverse_pointer
>>> ipaddress.ip_address("127.0.0.1").reverse_pointer
'1.0.0.127.in-addr.arpa'
null
cpython
3.10
ipaddress
_IPAddressBase.reverse_pointer
>>> ipaddress.ip_address("2001:db8::1").reverse_pointer
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'
null
cpython
3.10
telnetlib
__module__
>>> from telnetlib import Telnet
null
cpython
3.10
telnetlib
__module__
>>> tn = Telnet('www.python.org', 79) # connect to finger port
null
cpython
3.10
telnetlib
__module__
>>> tn.write(b'guido\r\n')
null
cpython
3.10
telnetlib
__module__
>>> print(tn.read_all())
null
cpython
3.10
telnetlib
__module__
>>>
null
cpython
3.10
_pydecimal
__module__
>>> from decimal import *
null
cpython
3.10
_pydecimal
__module__
>>> setcontext(ExtendedContext)
null
cpython
3.10
_pydecimal
__module__
>>> Decimal(0)
Decimal('0')
null
cpython
3.10
_pydecimal
__module__
>>> Decimal('1')
Decimal('1')
null
cpython
3.10
_pydecimal
__module__
>>> Decimal('-.0123')
Decimal('-0.0123')
null