mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-30 00:50:53 +00:00
fix docstring (#459)
This commit is contained in:
parent
cfae52437b
commit
1e728a2e0b
2 changed files with 60 additions and 33 deletions
|
|
@ -212,49 +212,76 @@ def unpackb(object packed, *, object object_hook=None, object list_hook=None,
|
||||||
|
|
||||||
|
|
||||||
cdef class Unpacker(object):
|
cdef class Unpacker(object):
|
||||||
"""
|
"""Streaming unpacker.
|
||||||
MessagePack Packer
|
|
||||||
|
|
||||||
Usage::
|
Arguments:
|
||||||
|
|
||||||
packer = Packer()
|
:param file_like:
|
||||||
astream.write(packer.pack(a))
|
File-like object having `.read(n)` method.
|
||||||
astream.write(packer.pack(b))
|
If specified, unpacker reads serialized data from it and :meth:`feed()` is not usable.
|
||||||
|
|
||||||
Packer's constructor has some keyword arguments:
|
:param int read_size:
|
||||||
|
Used as `file_like.read(read_size)`. (default: `min(16*1024, max_buffer_size)`)
|
||||||
|
|
||||||
:param callable default:
|
:param bool use_list:
|
||||||
Convert user type to builtin type that Packer supports.
|
If true, unpack msgpack array to Python list.
|
||||||
See also simplejson's document.
|
Otherwise, unpack to Python tuple. (default: True)
|
||||||
|
|
||||||
:param bool use_single_float:
|
:param bool raw:
|
||||||
Use single precision float type for float. (default: False)
|
If true, unpack msgpack raw to Python bytes.
|
||||||
|
Otherwise, unpack to Python str by decoding with UTF-8 encoding (default).
|
||||||
|
|
||||||
:param bool autoreset:
|
:param int timestamp:
|
||||||
Reset buffer after each pack and return its content as `bytes`. (default: True).
|
Control how timestamp type is unpacked:
|
||||||
If set this to false, use `bytes()` to get content and `.reset()` to clear buffer.
|
|
||||||
|
|
||||||
:param bool use_bin_type:
|
0 - Timestamp
|
||||||
Use bin type introduced in msgpack spec 2.0 for bytes.
|
1 - float (Seconds from the EPOCH)
|
||||||
It also enables str8 type for unicode. (default: True)
|
2 - int (Nanoseconds from the EPOCH)
|
||||||
|
3 - datetime.datetime (UTC). Python 2 is not supported.
|
||||||
|
|
||||||
:param bool strict_types:
|
:param bool strict_map_key:
|
||||||
If set to true, types will be checked to be exact. Derived classes
|
If true (default), only str or bytes are accepted for map (dict) keys.
|
||||||
from serializable types will not be serialized and will be
|
|
||||||
treated as unsupported type and forwarded to default.
|
|
||||||
Additionally tuples will not be serialized as lists.
|
|
||||||
This is useful when trying to implement accurate serialization
|
|
||||||
for python types.
|
|
||||||
|
|
||||||
:param bool datetime:
|
:param callable object_hook:
|
||||||
If set to true, datetime with tzinfo is packed into Timestamp type.
|
When specified, it should be callable.
|
||||||
Note that the tzinfo is stripped in the timestamp.
|
Unpacker calls it with a dict argument after unpacking msgpack map.
|
||||||
You can get UTC datetime with `timestamp=3` option of the Unpacker.
|
(See also simplejson)
|
||||||
(Python 2 is not supported).
|
|
||||||
|
:param callable object_pairs_hook:
|
||||||
|
When specified, it should be callable.
|
||||||
|
Unpacker calls it with a list of key-value pairs after unpacking msgpack map.
|
||||||
|
(See also simplejson)
|
||||||
|
|
||||||
:param str unicode_errors:
|
:param str unicode_errors:
|
||||||
The error handler for encoding unicode. (default: 'strict')
|
The error handler for decoding unicode. (default: 'strict')
|
||||||
DO NOT USE THIS!! This option is kept for very specific usage.
|
This option should be used only when you have msgpack data which
|
||||||
|
contains invalid UTF-8 string.
|
||||||
|
|
||||||
|
:param int max_buffer_size:
|
||||||
|
Limits size of data waiting unpacked. 0 means 2**32-1.
|
||||||
|
The default value is 100*1024*1024 (100MiB).
|
||||||
|
Raises `BufferFull` exception when it is insufficient.
|
||||||
|
You should set this parameter when unpacking data from untrusted source.
|
||||||
|
|
||||||
|
:param int max_str_len:
|
||||||
|
Deprecated, use *max_buffer_size* instead.
|
||||||
|
Limits max length of str. (default: max_buffer_size)
|
||||||
|
|
||||||
|
:param int max_bin_len:
|
||||||
|
Deprecated, use *max_buffer_size* instead.
|
||||||
|
Limits max length of bin. (default: max_buffer_size)
|
||||||
|
|
||||||
|
:param int max_array_len:
|
||||||
|
Limits max length of array.
|
||||||
|
(default: max_buffer_size)
|
||||||
|
|
||||||
|
:param int max_map_len:
|
||||||
|
Limits max length of map.
|
||||||
|
(default: max_buffer_size//2)
|
||||||
|
|
||||||
|
:param int max_ext_len:
|
||||||
|
Deprecated, use *max_buffer_size* instead.
|
||||||
|
Limits max size of ext type. (default: max_buffer_size)
|
||||||
|
|
||||||
Example of streaming deserialize from file-like object::
|
Example of streaming deserialize from file-like object::
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ class Unpacker(object):
|
||||||
|
|
||||||
Example of streaming deserialize from socket::
|
Example of streaming deserialize from socket::
|
||||||
|
|
||||||
unpacker = Unpacker(max_buffer_size)
|
unpacker = Unpacker()
|
||||||
while True:
|
while True:
|
||||||
buf = sock.recv(1024**2)
|
buf = sock.recv(1024**2)
|
||||||
if not buf:
|
if not buf:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue