@@ -37,36 +37,16 @@ Sadly, this doesn't work for upgrade install. After `pip install -U msgpack-pyt
3737msgpack is removed and `import msgpack ` fail.
3838
3939
40- Deprecating encoding option
41- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40+ Compatibility with old format
41+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4242
43- encoding and unicode_errors options are deprecated.
43+ You can use ``use_bin_type=False `` option to pack ``bytes ``
44+ object into raw type in old msgpack spec, instead of bin type in new msgpack spec.
4445
45- In case of packer, use UTF-8 always. Storing other than UTF-8 is not recommended.
46+ You can unpack old msgpack formatk using ``raw=True `` option.
47+ It unpacks str (raw) type in msgpack into Python bytes.
4648
47- For backward compatibility, you can use ``use_bin_type=False `` and pack ``bytes ``
48- object into msgpack raw type.
49-
50- In case of unpacker, there is new ``raw `` option. It is ``True `` by default
51- for backward compatibility, but it is changed to ``False `` in near future.
52- You can use ``raw=False `` instead of ``encoding='utf-8' ``.
53-
54- Planned backward incompatible changes
55- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56-
57- When msgpack 1.0, I planning these breaking changes:
58-
59- * packer and unpacker: Remove ``encoding `` and ``unicode_errors `` option.
60- * packer: Change default of ``use_bin_type `` option from False to True.
61- * unpacker: Change default of ``raw `` option from True to False.
62- * unpacker: Reduce all ``max_xxx_len `` options for typical usage.
63- * unpacker: Remove ``write_bytes `` option from all methods.
64-
65- To avoid these breaking changes breaks your application, please:
66-
67- * Don't use deprecated options.
68- * Pass ``use_bin_type `` and ``raw `` options explicitly.
69- * If your application handle large (>1MB) data, specify ``max_xxx_len `` options too.
49+ See note in below for detail.
7050
7151
7252Install
@@ -76,6 +56,7 @@ Install
7656
7757 $ pip install msgpack
7858
59+
7960Pure Python implementation
8061^^^^^^^^^^^^^^^^^^^^^^^^^^
8162
@@ -100,6 +81,13 @@ Without extension, using pure Python implementation on CPython runs slowly.
10081How to use
10182----------
10283
84+ .. note ::
85+
86+ In examples below, I use ``raw=False `` and ``use_bin_type=True `` for users
87+ using msgpack < 1.0.
88+ These options are default from msgpack 1.0 so you can omit them.
89+
90+
10391One-shot pack & unpack
10492^^^^^^^^^^^^^^^^^^^^^^
10593
@@ -252,36 +240,18 @@ Notes
252240string and binary type
253241^^^^^^^^^^^^^^^^^^^^^^
254242
255- Early versions of msgpack didn't distinguish string and binary types (like Python 1) .
243+ Early versions of msgpack didn't distinguish string and binary types.
256244The type for representing both string and binary types was named **raw **.
257245
258- For backward compatibility reasons, msgpack-python will still default all
259- strings to byte strings, unless you specify the ``use_bin_type=True `` option in
260- the packer. If you do so, it will use a non-standard type called **bin ** to
261- serialize byte arrays, and **raw ** becomes to mean **str **. If you want to
262- distinguish **bin ** and **raw ** in the unpacker, specify ``raw=False ``.
263-
264- Note that Python 2 defaults to byte-arrays over Unicode strings:
265-
266- .. code-block :: pycon
267-
268- >>> import msgpack
269- >>> msgpack.unpackb(msgpack.packb([b'spam', u'eggs']))
270- ['spam', 'eggs']
271- >>> msgpack.unpackb(msgpack.packb([b'spam', u'eggs'], use_bin_type=True),
272- raw=False)
273- ['spam', u'eggs']
274-
275- This is the same code in Python 3 (same behaviour, but Python 3 has a
276- different default):
246+ You can pack into and unpack from this old spec using ``use_bin_type=False ``
247+ and ``raw=True `` options.
277248
278249.. code-block :: pycon
279250
280251 >>> import msgpack
281- >>> msgpack.unpackb(msgpack.packb([b'spam', u'eggs']) )
252+ >>> msgpack.unpackb(msgpack.packb([b'spam', u'eggs'], use_bin_type=False), raw=True )
282253 [b'spam', b'eggs']
283- >>> msgpack.unpackb(msgpack.packb([b'spam', u'eggs'], use_bin_type=True),
284- raw=False)
254+ >>> msgpack.unpackb(msgpack.packb([b'spam', u'eggs'], use_bin_type=True), raw=False)
285255 [b'spam', 'eggs']
286256
287257
0 commit comments