123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- diff --git a/src/pip/_vendor/msgpack/fallback.py b/msgpack/fallback.py
- index c0e5fd66..c8c8c78a 100644
- --- a/src/pip/_vendor/msgpack/fallback.py
- +++ b/src/pip/_vendor/msgpack/fallback.py
- @@ -234,6 +234,12 @@ def __init__(self, file_like=None, read_size=0, use_list=True, raw=True,
-
- #: array of bytes fed.
- self._buffer = bytearray()
- + # Some very old pythons don't support `struct.unpack_from()` with a
- + # `bytearray`. So we wrap it in a `buffer()` there.
- + if sys.version_info < (2, 7, 6):
- + self._buffer_view = buffer(self._buffer)
- + else:
- + self._buffer_view = self._buffer
- #: Which position we currently reads
- self._buff_i = 0
-
- @@ -388,7 +394,7 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xc5:
- typ = TYPE_BIN
- self._reserve(2)
- - n = struct.unpack_from(">H", self._buffer, self._buff_i)[0]
- + n = struct.unpack_from(">H", self._buffer_view, self._buff_i)[0]
- self._buff_i += 2
- if n > self._max_bin_len:
- raise UnpackValueError("%s exceeds max_bin_len(%s)" % (n, self._max_bin_len))
- @@ -396,7 +402,7 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xc6:
- typ = TYPE_BIN
- self._reserve(4)
- - n = struct.unpack_from(">I", self._buffer, self._buff_i)[0]
- + n = struct.unpack_from(">I", self._buffer_view, self._buff_i)[0]
- self._buff_i += 4
- if n > self._max_bin_len:
- raise UnpackValueError("%s exceeds max_bin_len(%s)" % (n, self._max_bin_len))
- @@ -404,7 +410,7 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xc7: # ext 8
- typ = TYPE_EXT
- self._reserve(2)
- - L, n = struct.unpack_from('Bb', self._buffer, self._buff_i)
- + L, n = struct.unpack_from('Bb', self._buffer_view, self._buff_i)
- self._buff_i += 2
- if L > self._max_ext_len:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (L, self._max_ext_len))
- @@ -412,7 +418,7 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xc8: # ext 16
- typ = TYPE_EXT
- self._reserve(3)
- - L, n = struct.unpack_from('>Hb', self._buffer, self._buff_i)
- + L, n = struct.unpack_from('>Hb', self._buffer_view, self._buff_i)
- self._buff_i += 3
- if L > self._max_ext_len:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (L, self._max_ext_len))
- @@ -420,18 +426,18 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xc9: # ext 32
- typ = TYPE_EXT
- self._reserve(5)
- - L, n = struct.unpack_from('>Ib', self._buffer, self._buff_i)
- + L, n = struct.unpack_from('>Ib', self._buffer_view, self._buff_i)
- self._buff_i += 5
- if L > self._max_ext_len:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (L, self._max_ext_len))
- obj = self._read(L)
- elif b == 0xca:
- self._reserve(4)
- - obj = struct.unpack_from(">f", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">f", self._buffer_view, self._buff_i)[0]
- self._buff_i += 4
- elif b == 0xcb:
- self._reserve(8)
- - obj = struct.unpack_from(">d", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">d", self._buffer_view, self._buff_i)[0]
- self._buff_i += 8
- elif b == 0xcc:
- self._reserve(1)
- @@ -439,66 +445,66 @@ def _read_header(self, execute=EX_CONSTRUCT):
- self._buff_i += 1
- elif b == 0xcd:
- self._reserve(2)
- - obj = struct.unpack_from(">H", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">H", self._buffer_view, self._buff_i)[0]
- self._buff_i += 2
- elif b == 0xce:
- self._reserve(4)
- - obj = struct.unpack_from(">I", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">I", self._buffer_view, self._buff_i)[0]
- self._buff_i += 4
- elif b == 0xcf:
- self._reserve(8)
- - obj = struct.unpack_from(">Q", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">Q", self._buffer_view, self._buff_i)[0]
- self._buff_i += 8
- elif b == 0xd0:
- self._reserve(1)
- - obj = struct.unpack_from("b", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from("b", self._buffer_view, self._buff_i)[0]
- self._buff_i += 1
- elif b == 0xd1:
- self._reserve(2)
- - obj = struct.unpack_from(">h", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">h", self._buffer_view, self._buff_i)[0]
- self._buff_i += 2
- elif b == 0xd2:
- self._reserve(4)
- - obj = struct.unpack_from(">i", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">i", self._buffer_view, self._buff_i)[0]
- self._buff_i += 4
- elif b == 0xd3:
- self._reserve(8)
- - obj = struct.unpack_from(">q", self._buffer, self._buff_i)[0]
- + obj = struct.unpack_from(">q", self._buffer_view, self._buff_i)[0]
- self._buff_i += 8
- elif b == 0xd4: # fixext 1
- typ = TYPE_EXT
- if self._max_ext_len < 1:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (1, self._max_ext_len))
- self._reserve(2)
- - n, obj = struct.unpack_from("b1s", self._buffer, self._buff_i)
- + n, obj = struct.unpack_from("b1s", self._buffer_view, self._buff_i)
- self._buff_i += 2
- elif b == 0xd5: # fixext 2
- typ = TYPE_EXT
- if self._max_ext_len < 2:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (2, self._max_ext_len))
- self._reserve(3)
- - n, obj = struct.unpack_from("b2s", self._buffer, self._buff_i)
- + n, obj = struct.unpack_from("b2s", self._buffer_view, self._buff_i)
- self._buff_i += 3
- elif b == 0xd6: # fixext 4
- typ = TYPE_EXT
- if self._max_ext_len < 4:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (4, self._max_ext_len))
- self._reserve(5)
- - n, obj = struct.unpack_from("b4s", self._buffer, self._buff_i)
- + n, obj = struct.unpack_from("b4s", self._buffer_view, self._buff_i)
- self._buff_i += 5
- elif b == 0xd7: # fixext 8
- typ = TYPE_EXT
- if self._max_ext_len < 8:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (8, self._max_ext_len))
- self._reserve(9)
- - n, obj = struct.unpack_from("b8s", self._buffer, self._buff_i)
- + n, obj = struct.unpack_from("b8s", self._buffer_view, self._buff_i)
- self._buff_i += 9
- elif b == 0xd8: # fixext 16
- typ = TYPE_EXT
- if self._max_ext_len < 16:
- raise UnpackValueError("%s exceeds max_ext_len(%s)" % (16, self._max_ext_len))
- self._reserve(17)
- - n, obj = struct.unpack_from("b16s", self._buffer, self._buff_i)
- + n, obj = struct.unpack_from("b16s", self._buffer_view, self._buff_i)
- self._buff_i += 17
- elif b == 0xd9:
- typ = TYPE_RAW
- @@ -511,7 +517,7 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xda:
- typ = TYPE_RAW
- self._reserve(2)
- - n, = struct.unpack_from(">H", self._buffer, self._buff_i)
- + n, = struct.unpack_from(">H", self._buffer_view, self._buff_i)
- self._buff_i += 2
- if n > self._max_str_len:
- raise UnpackValueError("%s exceeds max_str_len(%s)", n, self._max_str_len)
- @@ -519,7 +525,7 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xdb:
- typ = TYPE_RAW
- self._reserve(4)
- - n, = struct.unpack_from(">I", self._buffer, self._buff_i)
- + n, = struct.unpack_from(">I", self._buffer_view, self._buff_i)
- self._buff_i += 4
- if n > self._max_str_len:
- raise UnpackValueError("%s exceeds max_str_len(%s)", n, self._max_str_len)
- @@ -527,27 +533,27 @@ def _read_header(self, execute=EX_CONSTRUCT):
- elif b == 0xdc:
- typ = TYPE_ARRAY
- self._reserve(2)
- - n, = struct.unpack_from(">H", self._buffer, self._buff_i)
- + n, = struct.unpack_from(">H", self._buffer_view, self._buff_i)
- self._buff_i += 2
- if n > self._max_array_len:
- raise UnpackValueError("%s exceeds max_array_len(%s)", n, self._max_array_len)
- elif b == 0xdd:
- typ = TYPE_ARRAY
- self._reserve(4)
- - n, = struct.unpack_from(">I", self._buffer, self._buff_i)
- + n, = struct.unpack_from(">I", self._buffer_view, self._buff_i)
- self._buff_i += 4
- if n > self._max_array_len:
- raise UnpackValueError("%s exceeds max_array_len(%s)", n, self._max_array_len)
- elif b == 0xde:
- self._reserve(2)
- - n, = struct.unpack_from(">H", self._buffer, self._buff_i)
- + n, = struct.unpack_from(">H", self._buffer_view, self._buff_i)
- self._buff_i += 2
- if n > self._max_map_len:
- raise UnpackValueError("%s exceeds max_map_len(%s)", n, self._max_map_len)
- typ = TYPE_MAP
- elif b == 0xdf:
- self._reserve(4)
- - n, = struct.unpack_from(">I", self._buffer, self._buff_i)
- + n, = struct.unpack_from(">I", self._buffer_view, self._buff_i)
- self._buff_i += 4
- if n > self._max_map_len:
- raise UnpackValueError("%s exceeds max_map_len(%s)", n, self._max_map_len)
|