diff options
author | INADA Naoki <songofacandy@gmail.com> | 2013-10-17 09:15:19 +0900 |
---|---|---|
committer | INADA Naoki <songofacandy@gmail.com> | 2013-10-17 09:15:19 +0900 |
commit | 85eaff344b74092ccf076ba2465e9bdb1537409b (patch) | |
tree | 0a76eb69cceebb89472eba3279afc64f1efcd1a9 /msgpack/fallback.py | |
parent | 84f6b100190049a5d1bceb916208eeae2a3d2591 (diff) | |
download | msgpack-python-85eaff344b74092ccf076ba2465e9bdb1537409b.tar.gz |
Add bin type support for fallback Unpacker.
Diffstat (limited to 'msgpack/fallback.py')
-rw-r--r-- | msgpack/fallback.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py index 49a2bc5..901c6c8 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -57,6 +57,7 @@ TYPE_IMMEDIATE = 0 TYPE_ARRAY = 1 TYPE_MAP = 2 TYPE_RAW = 3 +TYPE_BIN = 4 DEFAULT_RECURSE_LIMIT=511 @@ -297,6 +298,10 @@ class Unpacker(object): obj = struct.unpack(">i", self._fb_read(4, write_bytes))[0] elif b == 0xd3: obj = struct.unpack(">q", self._fb_read(8, write_bytes))[0] + elif b == 0xd9: + n = struct.unpack("B", self._fb_read(1, write_bytes))[0] + obj = self._fb_read(n, write_bytes) + typ = TYPE_RAW elif b == 0xda: n = struct.unpack(">H", self._fb_read(2, write_bytes))[0] obj = self._fb_read(n, write_bytes) @@ -305,6 +310,18 @@ class Unpacker(object): n = struct.unpack(">I", self._fb_read(4, write_bytes))[0] obj = self._fb_read(n, write_bytes) typ = TYPE_RAW + elif b == 0xc4: + n = struct.unpack("B", self._fb_read(1, write_bytes))[0] + obj = self._fb_read(n, write_bytes) + typ = TYPE_BIN + elif b == 0xc5: + n = struct.unpack(">H", self._fb_read(2, write_bytes))[0] + obj = self._fb_read(n, write_bytes) + typ = TYPE_BIN + elif b == 0xc6: + n = struct.unpack(">I", self._fb_read(4, write_bytes))[0] + obj = self._fb_read(n, write_bytes) + typ = TYPE_BIN elif b == 0xdc: n = struct.unpack(">H", self._fb_read(2, write_bytes))[0] typ = TYPE_ARRAY @@ -373,6 +390,8 @@ class Unpacker(object): if self._encoding is not None: obj = obj.decode(self._encoding, self._unicode_errors) return obj + if typ == TYPE_BIN: + return obj assert typ == TYPE_IMMEDIATE return obj |