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

Function read_bytes1

Lib/pickletools.py:472–487  ·  view source on GitHub ↗

r""" >>> import io >>> read_bytes1(io.BytesIO(b"\x00")) b'' >>> read_bytes1(io.BytesIO(b"\x03abcdef")) b'abc'

(f)

Source from the content-addressed store, hash-verified

470
471
472def read_bytes1(f):
473 r"""
474 >>> import io
475 >>> read_bytes1(io.BytesIO(b"\x00"))
476 b''
477 >>> read_bytes1(io.BytesIO(b"\x03abcdef"))
478 b'abc'
479 """
480
481 n = read_uint1(f)
482 assert n >= 0
483 data = f.read(n)
484 if len(data) == n:
485 return data
486 raise ValueError("expected %d bytes in a bytes1, but only %d remain" %
487 (n, len(data)))
488
489bytes1 = ArgumentDescriptor(
490 name="bytes1",

Callers

nothing calls this directly

Calls 2

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…