mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-04-10 13:30:17 +00:00
Deprecate implementation module's unpack() (#290)
This commit is contained in:
parent
f38c1a3674
commit
ae3a6ba0b0
3 changed files with 23 additions and 25 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,18 @@ def packb(o, **kwargs):
|
|||
"""
|
||||
return Packer(**kwargs).pack(o)
|
||||
|
||||
|
||||
def unpack(stream, **kwargs):
|
||||
"""
|
||||
Unpack an object from `stream`.
|
||||
|
||||
Raises `ExtraData` when `stream` contains extra bytes.
|
||||
See :class:`Unpacker` for options.
|
||||
"""
|
||||
data = stream.read()
|
||||
return unpackb(data, **kwargs)
|
||||
|
||||
|
||||
# alias for compatibility to simplejson/marshal/pickle.
|
||||
load = unpack
|
||||
loads = unpackb
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue