Kaydet (Commit) 5a4e3d8f authored tarafından Jelle Zijlstra's avatar Jelle Zijlstra Kaydeden (comit) Serhiy Storchaka

bpo-30174: Remove duplicate definition from pickletools (#1301)

There were two almost identical definitions of bytes1.
üst 5bccca58
...@@ -469,35 +469,6 @@ string4 = ArgumentDescriptor( ...@@ -469,35 +469,6 @@ string4 = ArgumentDescriptor(
""") """)
def read_bytes1(f):
r"""
>>> import io
>>> read_bytes1(io.BytesIO(b"\x00"))
b''
>>> read_bytes1(io.BytesIO(b"\x03abcdef"))
b'abc'
"""
n = read_uint1(f)
assert n >= 0
data = f.read(n)
if len(data) == n:
return data
raise ValueError("expected %d bytes in a bytes1, but only %d remain" %
(n, len(data)))
bytes1 = ArgumentDescriptor(
name="bytes1",
n=TAKEN_FROM_ARGUMENT1,
reader=read_bytes1,
doc="""A counted bytes string.
The first argument is a 1-byte unsigned int giving the number
of bytes in the string, and the second argument is that many
bytes.
""")
def read_bytes1(f): def read_bytes1(f):
r""" r"""
>>> import io >>> import io
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment