Skip to content

Commit afa28fb

Browse files
committed
add support to unpack all ext formats
1 parent c727440 commit afa28fb

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

msgpack/fallback.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,33 @@ def _read_header(self, execute=EX_CONSTRUCT, write_bytes=None):
336336
elif b == 0xdf:
337337
n = struct.unpack(">I", self._fb_read(4, write_bytes))[0]
338338
typ = TYPE_MAP
339-
elif b == 0xc9:
339+
elif b == 0xd4: # fixext 1
340+
typ = struct.unpack(">B", self._fb_read(1, write_bytes))[0]
341+
n = 1
342+
typ += EXTENDED_TYPE
343+
elif b == 0xd5: # fixext 2
344+
typ = struct.unpack(">B", self._fb_read(1, write_bytes))[0]
345+
n = 2
346+
typ += EXTENDED_TYPE
347+
elif b == 0xd6: # fixext 4
348+
typ = struct.unpack(">B", self._fb_read(1, write_bytes))[0]
349+
n = 4
350+
typ += EXTENDED_TYPE
351+
elif b == 0xd7: # fixext 8
352+
typ = struct.unpack(">B", self._fb_read(1, write_bytes))[0]
353+
n = 8
354+
typ += EXTENDED_TYPE
355+
elif b == 0xd8: # fixext 16
356+
typ = struct.unpack(">B", self._fb_read(1, write_bytes))[0]
357+
n = 16
358+
typ += EXTENDED_TYPE
359+
elif b == 0xc7: # ext 8
360+
n, typ = struct.unpack(">Bb", self._fb_read(2, write_bytes))
361+
typ += EXTENDED_TYPE
362+
elif b == 0xc8: # ext 16
363+
n, typ = struct.unpack(">Hb", self._fb_read(3, write_bytes))
364+
typ += EXTENDED_TYPE
365+
elif b == 0xc9: # ext 32
340366
n, typ = struct.unpack(">Ib", self._fb_read(5, write_bytes))
341367
typ += EXTENDED_TYPE
342368
else:

0 commit comments

Comments
 (0)