Unpack an object from `packed`. Raises ``ExtraData`` when *packed* contains extra bytes. Raises ``ValueError`` when *packed* is incomplete. Raises ``FormatError`` when *packed* is not valid msgpack. Raises ``StackError`` when *packed* contains too nested. Other exceptions c
(packed, **kwargs)
| 75 | |
| 76 | |
| 77 | def unpackb(packed, **kwargs): |
| 78 | """ |
| 79 | Unpack an object from `packed`. |
| 80 | |
| 81 | Raises ``ExtraData`` when *packed* contains extra bytes. |
| 82 | Raises ``ValueError`` when *packed* is incomplete. |
| 83 | Raises ``FormatError`` when *packed* is not valid msgpack. |
| 84 | Raises ``StackError`` when *packed* contains too nested. |
| 85 | Other exceptions can be raised during unpacking. |
| 86 | |
| 87 | See :class:`Unpacker` for options. |
| 88 | """ |
| 89 | unpacker = Unpacker(None, max_buffer_size=len(packed), **kwargs) |
| 90 | unpacker.feed(packed) |
| 91 | try: |
| 92 | ret = unpacker._unpack() |
| 93 | except OutOfData: |
| 94 | raise ValueError("Unpack failed: incomplete input") |
| 95 | except RecursionError: |
| 96 | raise StackError |
| 97 | if unpacker._got_extradata(): |
| 98 | raise ExtraData(ret, unpacker._get_extradata()) |
| 99 | return ret |
| 100 | |
| 101 | |
| 102 | _NO_FORMAT_USED = "" |
no test coverage detected
searching dependent graphs…