@@ -60,7 +60,7 @@ msgpack provides ``dumps`` and ``loads`` as an alias for compatibility with
6060.. code-block :: pycon
6161
6262 >>> import msgpack
63- >>> msgpack.packb([1, 2, 3])
63+ >>> msgpack.packb([1, 2, 3], use_bin_type=True )
6464 '\x93\x01\x02\x03'
6565 >>> msgpack.unpackb(_)
6666 [1, 2, 3]
@@ -91,13 +91,13 @@ stream (or from bytes provided through its ``feed`` method).
9191
9292 buf = BytesIO()
9393 for i in range (100 ):
94- buf.write(msgpack.packb(range (i)))
94+ buf.write(msgpack.packb(range (i), use_bin_type = True ))
9595
9696 buf.seek(0 )
9797
9898 unpacker = msgpack.Unpacker(buf)
9999 for unpacked in unpacker:
100- print unpacked
100+ print ( unpacked)
101101
102102
103103 Packing/unpacking of custom data type
@@ -109,7 +109,6 @@ It is also possible to pack/unpack custom data types. Here is an example for
109109.. code-block :: python
110110
111111 import datetime
112-
113112 import msgpack
114113
115114 useful_dict = {
@@ -128,7 +127,7 @@ It is also possible to pack/unpack custom data types. Here is an example for
128127 return obj
129128
130129
131- packed_dict = msgpack.packb(useful_dict, default = encode_datetime)
130+ packed_dict = msgpack.packb(useful_dict, default = encode_datetime, use_bin_type = True )
132131 this_dict_again = msgpack.unpackb(packed_dict, object_hook = decode_datetime)
133132
134133 ``Unpacker ``'s ``object_hook `` callback receives a dict; the
@@ -208,6 +207,10 @@ the packer. If you do so, it will use a non-standard type called **bin** to
208207serialize byte arrays, and **raw ** becomes to mean **str **. If you want to
209208distinguish **bin ** and **raw ** in the unpacker, specify `encoding='utf-8' `.
210209
210+ **In future version, default value of ``use_bin_type`` will be changed to ``False``.
211+ To avoid this change will break your code, you must specify it explicitly
212+ even when you want to use old format. **
213+
211214Note that Python 2 defaults to byte-arrays over Unicode strings:
212215
213216.. code-block :: pycon
0 commit comments