Revert "Move unpack() from each implementation to __init__. (#286)"

This reverts commit da902f9c1d.
This commit is contained in:
INADA Naoki 2018-02-23 11:32:26 +09:00 committed by GitHub
parent 9bf38105f7
commit 9455fccc52
3 changed files with 39 additions and 14 deletions

View file

@ -211,6 +211,32 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
raise UnpackValueError("Unpack failed: error = %d" % (ret,))
def unpack(object stream, object object_hook=None, object list_hook=None,
bint use_list=1, encoding=None, unicode_errors=None,
object_pairs_hook=None, ext_hook=ExtType,
Py_ssize_t max_str_len=2147483647, # 2**32-1
Py_ssize_t max_bin_len=2147483647,
Py_ssize_t max_array_len=2147483647,
Py_ssize_t max_map_len=2147483647,
Py_ssize_t max_ext_len=2147483647):
"""
Unpack an object from `stream`.
Raises `ValueError` when `stream` has extra bytes.
See :class:`Unpacker` for options.
"""
return unpackb(stream.read(), use_list=use_list,
object_hook=object_hook, object_pairs_hook=object_pairs_hook, list_hook=list_hook,
encoding=encoding, unicode_errors=unicode_errors, ext_hook=ext_hook,
max_str_len=max_str_len,
max_bin_len=max_bin_len,
max_array_len=max_array_len,
max_map_len=max_map_len,
max_ext_len=max_ext_len,
)
cdef class Unpacker(object):
"""Streaming unpacker.