mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-11-09 14:01:03 +00:00
parent
ae8d469482
commit
da902f9c1d
3 changed files with 14 additions and 39 deletions
|
|
@ -19,13 +19,13 @@ class ExtType(namedtuple('ExtType', 'code data')):
|
|||
|
||||
import os
|
||||
if os.environ.get('MSGPACK_PUREPYTHON'):
|
||||
from msgpack.fallback import Packer, unpack, unpackb, Unpacker
|
||||
from msgpack.fallback import Packer, unpackb, Unpacker
|
||||
else:
|
||||
try:
|
||||
from msgpack._packer import Packer
|
||||
from msgpack._unpacker import unpack, unpackb, Unpacker
|
||||
from msgpack._unpacker import unpackb, Unpacker
|
||||
except ImportError:
|
||||
from msgpack.fallback import Packer, unpack, unpackb, Unpacker
|
||||
from msgpack.fallback import Packer, unpackb, Unpacker
|
||||
|
||||
|
||||
def pack(o, stream, **kwargs):
|
||||
|
|
@ -46,6 +46,17 @@ def packb(o, **kwargs):
|
|||
"""
|
||||
return Packer(**kwargs).pack(o)
|
||||
|
||||
|
||||
def unpack(stream, **kwargs):
|
||||
"""
|
||||
Unpack an object from `stream`.
|
||||
|
||||
Raises `ExtraData` when `packed` contains extra bytes.
|
||||
See :class:`Unpacker` for options.
|
||||
"""
|
||||
return unpackb(stream.read(), **kwargs)
|
||||
|
||||
|
||||
# alias for compatibility to simplejson/marshal/pickle.
|
||||
load = unpack
|
||||
loads = unpackb
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue