MCPcopy Index your code
hub / github.com/python/cpython / read_long1

Function read_long1

Lib/pickletools.py:873–892  ·  view source on GitHub ↗

r""" >>> import io >>> read_long1(io.BytesIO(b"\x00")) 0 >>> read_long1(io.BytesIO(b"\x02\xff\x00")) 255 >>> read_long1(io.BytesIO(b"\x02\xff\x7f")) 32767 >>> read_long1(io.BytesIO(b"\x02\x00\xff")) -256 >>> read_long1(io.BytesIO(b"\x02\x00\x80")) -32768

(f)

Source from the content-addressed store, hash-verified

871from pickle import decode_long
872
873def read_long1(f):
874 r"""
875 >>> import io
876 >>> read_long1(io.BytesIO(b"\x00"))
877 0
878 >>> read_long1(io.BytesIO(b"\x02\xff\x00"))
879 255
880 >>> read_long1(io.BytesIO(b"\x02\xff\x7f"))
881 32767
882 >>> read_long1(io.BytesIO(b"\x02\x00\xff"))
883 -256
884 >>> read_long1(io.BytesIO(b"\x02\x00\x80"))
885 -32768
886 """
887
888 n = read_uint1(f)
889 data = f.read(n)
890 if len(data) != n:
891 raise ValueError("not enough data in stream to read long1")
892 return decode_long(data)
893
894long1 = ArgumentDescriptor(
895 name="long1",

Callers

nothing calls this directly

Calls 3

decode_longFunction · 0.90
read_uint1Function · 0.85
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…