comparison mercurial/utils/cborutil.py @ 40125:b638219a23c3

cborutil: cast bytearray to bytes This code didn't like passing in bytearray instances. Let's cast bytearray to bytes so it works. Differential Revision: https://phab.mercurial-scm.org/D4914
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 04 Oct 2018 15:08:42 -0700
parents 62160d3077cd
children b6387a65851d
comparison
equal deleted inserted replaced
40124:627b0f9baeaf 40125:b638219a23c3
923 923
924 * Bool indicating whether new values are available for retrieval. 924 * Bool indicating whether new values are available for retrieval.
925 * Integer number of bytes decoded from the new input. 925 * Integer number of bytes decoded from the new input.
926 * Integer number of bytes wanted to decode the next value. 926 * Integer number of bytes wanted to decode the next value.
927 """ 927 """
928 # We /might/ be able to support passing a bytearray all the
929 # way through. For now, let's cheat.
930 if isinstance(b, bytearray):
931 b = bytes(b)
932
928 # Our strategy for buffering is to aggregate the incoming chunks in a 933 # Our strategy for buffering is to aggregate the incoming chunks in a
929 # list until we've received enough data to decode the next item. 934 # list until we've received enough data to decode the next item.
930 # This is slightly more complicated than using an ``io.BytesIO`` 935 # This is slightly more complicated than using an ``io.BytesIO``
931 # or continuously concatenating incoming data. However, because it 936 # or continuously concatenating incoming data. However, because it
932 # isn't constantly reallocating backing memory for a growing buffer, 937 # isn't constantly reallocating backing memory for a growing buffer,