From 9396c44f0e62c7b71f9963948c86d6e910308349 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2017 07:41:11 -0700 Subject: [PATCH 1/2] remove duplicate object from pickletools There's another almost identical definition of bytes1 above this one. The only difference is a minor one in the docstring: the first one has "the number of bytes in the string" and the second one has just "the number of bytes". I like the first wording better so I kept it. --- Lib/pickletools.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/Lib/pickletools.py b/Lib/pickletools.py index 5e129b5b56373b..10952f4feb3781 100644 --- a/Lib/pickletools.py +++ b/Lib/pickletools.py @@ -498,34 +498,6 @@ def read_bytes1(f): """) -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, and the second argument is that many bytes. - """) - - def read_bytes4(f): r""" >>> import io From 1d1f3f74085d24f4c9bc2974b59e3fa7781728df Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2017 08:47:36 -0700 Subject: [PATCH 2/2] use the other doc variant --- Lib/pickletools.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/pickletools.py b/Lib/pickletools.py index 10952f4feb3781..0c8dddc10bbc7e 100644 --- a/Lib/pickletools.py +++ b/Lib/pickletools.py @@ -493,8 +493,7 @@ def read_bytes1(f): 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. + of bytes, and the second argument is that many bytes. """)