msgpack 1.0.8__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {msgpack-1.0.8/msgpack.egg-info → msgpack-1.1.0}/PKG-INFO +54 -77
- {msgpack-1.0.8 → msgpack-1.1.0}/README.md +53 -76
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/__init__.py +8 -8
- msgpack-1.0.8/msgpack/_cmsgpack.cpp → msgpack-1.1.0/msgpack/_cmsgpack.c +5159 -4870
- msgpack-1.1.0/msgpack/_packer.pyx +358 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/_unpacker.pyx +2 -2
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/ext.py +5 -3
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/fallback.py +29 -51
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/pack.h +1 -21
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/pack_template.h +7 -231
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/unpack.h +5 -5
- msgpack-1.1.0/msgpack/unpack_container_header.h +51 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/unpack_template.h +22 -63
- {msgpack-1.0.8 → msgpack-1.1.0/msgpack.egg-info}/PKG-INFO +54 -77
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack.egg-info/SOURCES.txt +2 -2
- {msgpack-1.0.8 → msgpack-1.1.0}/pyproject.toml +7 -17
- msgpack-1.1.0/setup.py +32 -0
- msgpack-1.1.0/test/test_buffer.py +49 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_except.py +3 -2
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_extension.py +1 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_memoryview.py +2 -1
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_newspec.py +1 -1
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_obj.py +1 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_pack.py +3 -3
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_read_size.py +2 -1
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_seq.py +3 -3
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_sequnpack.py +4 -3
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_stricttype.py +2 -1
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_subtype.py +2 -1
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_timestamp.py +18 -1
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_unpack.py +4 -7
- msgpack-1.0.8/msgpack/_packer.pyx +0 -374
- msgpack-1.0.8/msgpack/buff_converter.h +0 -8
- msgpack-1.0.8/setup.py +0 -77
- msgpack-1.0.8/test/test_buffer.py +0 -29
- {msgpack-1.0.8 → msgpack-1.1.0}/COPYING +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/MANIFEST.in +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/_cmsgpack.pyx +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/exceptions.py +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/sysdep.h +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack/unpack_define.h +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack.egg-info/dependency_links.txt +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/msgpack.egg-info/top_level.txt +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/setup.cfg +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_case.py +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_format.py +0 -0
- {msgpack-1.0.8 → msgpack-1.1.0}/test/test_limits.py +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: msgpack
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: MessagePack serializer
|
|
5
5
|
Author-email: Inada Naoki <songofacandy@gmail.com>
|
|
6
6
|
License: Apache 2.0
|
|
@@ -39,53 +39,6 @@ It lets you exchange data among multiple languages like JSON.
|
|
|
39
39
|
But it's faster and smaller.
|
|
40
40
|
This package provides CPython bindings for reading and writing MessagePack data.
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
## Very important notes for existing users
|
|
44
|
-
|
|
45
|
-
### PyPI package name
|
|
46
|
-
|
|
47
|
-
Package name on PyPI was changed from `msgpack-python` to `msgpack` from 0.5.
|
|
48
|
-
|
|
49
|
-
When upgrading from msgpack-0.4 or earlier, do `pip uninstall msgpack-python` before
|
|
50
|
-
`pip install -U msgpack`.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### Compatibility with the old format
|
|
54
|
-
|
|
55
|
-
You can use `use_bin_type=False` option to pack `bytes`
|
|
56
|
-
object into raw type in the old msgpack spec, instead of bin type in new msgpack spec.
|
|
57
|
-
|
|
58
|
-
You can unpack old msgpack format using `raw=True` option.
|
|
59
|
-
It unpacks str (raw) type in msgpack into Python bytes.
|
|
60
|
-
|
|
61
|
-
See note below for detail.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
### Major breaking changes in msgpack 1.0
|
|
65
|
-
|
|
66
|
-
* Python 2
|
|
67
|
-
|
|
68
|
-
* The extension module does not support Python 2 anymore.
|
|
69
|
-
The pure Python implementation (`msgpack.fallback`) is used for Python 2.
|
|
70
|
-
|
|
71
|
-
* Packer
|
|
72
|
-
|
|
73
|
-
* `use_bin_type=True` by default. bytes are encoded in bin type in msgpack.
|
|
74
|
-
**If you are still using Python 2, you must use unicode for all string types.**
|
|
75
|
-
You can use `use_bin_type=False` to encode into old msgpack format.
|
|
76
|
-
* `encoding` option is removed. UTF-8 is used always.
|
|
77
|
-
|
|
78
|
-
* Unpacker
|
|
79
|
-
|
|
80
|
-
* `raw=False` by default. It assumes str types are valid UTF-8 string
|
|
81
|
-
and decode them to Python str (unicode) object.
|
|
82
|
-
* `encoding` option is removed. You can use `raw=True` to support old format.
|
|
83
|
-
* Default value of `max_buffer_size` is changed from 0 to 100 MiB.
|
|
84
|
-
* Default value of `strict_map_key` is changed to True to avoid hashdos.
|
|
85
|
-
You need to pass `strict_map_key=False` if you have data which contain map keys
|
|
86
|
-
which type is not bytes or str.
|
|
87
|
-
|
|
88
|
-
|
|
89
42
|
## Install
|
|
90
43
|
|
|
91
44
|
```
|
|
@@ -94,12 +47,9 @@ $ pip install msgpack
|
|
|
94
47
|
|
|
95
48
|
### Pure Python implementation
|
|
96
49
|
|
|
97
|
-
The extension module in msgpack (`msgpack._cmsgpack`) does not support
|
|
98
|
-
Python 2 and PyPy.
|
|
99
|
-
|
|
100
|
-
But msgpack provides a pure Python implementation (`msgpack.fallback`)
|
|
101
|
-
for PyPy and Python 2.
|
|
50
|
+
The extension module in msgpack (`msgpack._cmsgpack`) does not support PyPy.
|
|
102
51
|
|
|
52
|
+
But msgpack provides a pure Python implementation (`msgpack.fallback`) for PyPy.
|
|
103
53
|
|
|
104
54
|
|
|
105
55
|
### Windows
|
|
@@ -111,10 +61,6 @@ Without extension, using pure Python implementation on CPython runs slowly.
|
|
|
111
61
|
|
|
112
62
|
## How to use
|
|
113
63
|
|
|
114
|
-
NOTE: In examples below, I use `raw=False` and `use_bin_type=True` for users
|
|
115
|
-
using msgpack < 1.0. These options are default from msgpack 1.0 so you can omit them.
|
|
116
|
-
|
|
117
|
-
|
|
118
64
|
### One-shot pack & unpack
|
|
119
65
|
|
|
120
66
|
Use `packb` for packing and `unpackb` for unpacking.
|
|
@@ -126,23 +72,13 @@ msgpack provides `dumps` and `loads` as an alias for compatibility with
|
|
|
126
72
|
|
|
127
73
|
```pycon
|
|
128
74
|
>>> import msgpack
|
|
129
|
-
>>> msgpack.packb([1, 2, 3]
|
|
75
|
+
>>> msgpack.packb([1, 2, 3])
|
|
130
76
|
'\x93\x01\x02\x03'
|
|
131
|
-
>>> msgpack.unpackb(_
|
|
77
|
+
>>> msgpack.unpackb(_)
|
|
132
78
|
[1, 2, 3]
|
|
133
79
|
```
|
|
134
80
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```pycon
|
|
138
|
-
>>> msgpack.unpackb(b'\x93\x01\x02\x03', use_list=False, raw=False)
|
|
139
|
-
(1, 2, 3)
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
You should always specify the `use_list` keyword argument for backward compatibility.
|
|
143
|
-
See performance issues relating to `use_list option`_ below.
|
|
144
|
-
|
|
145
|
-
Read the docstring for other options.
|
|
81
|
+
Read the docstring for options.
|
|
146
82
|
|
|
147
83
|
|
|
148
84
|
### Streaming unpacking
|
|
@@ -156,11 +92,11 @@ from io import BytesIO
|
|
|
156
92
|
|
|
157
93
|
buf = BytesIO()
|
|
158
94
|
for i in range(100):
|
|
159
|
-
buf.write(msgpack.packb(i
|
|
95
|
+
buf.write(msgpack.packb(i))
|
|
160
96
|
|
|
161
97
|
buf.seek(0)
|
|
162
98
|
|
|
163
|
-
unpacker = msgpack.Unpacker(buf
|
|
99
|
+
unpacker = msgpack.Unpacker(buf)
|
|
164
100
|
for unpacked in unpacker:
|
|
165
101
|
print(unpacked)
|
|
166
102
|
```
|
|
@@ -191,14 +127,17 @@ def encode_datetime(obj):
|
|
|
191
127
|
return obj
|
|
192
128
|
|
|
193
129
|
|
|
194
|
-
packed_dict = msgpack.packb(useful_dict, default=encode_datetime
|
|
195
|
-
this_dict_again = msgpack.unpackb(packed_dict, object_hook=decode_datetime
|
|
130
|
+
packed_dict = msgpack.packb(useful_dict, default=encode_datetime)
|
|
131
|
+
this_dict_again = msgpack.unpackb(packed_dict, object_hook=decode_datetime)
|
|
196
132
|
```
|
|
197
133
|
|
|
198
134
|
`Unpacker`'s `object_hook` callback receives a dict; the
|
|
199
135
|
`object_pairs_hook` callback may instead be used to receive a list of
|
|
200
136
|
key-value pairs.
|
|
201
137
|
|
|
138
|
+
NOTE: msgpack can encode datetime with tzinfo into standard ext type for now.
|
|
139
|
+
See `datetime` option in `Packer` docstring.
|
|
140
|
+
|
|
202
141
|
|
|
203
142
|
### Extended types
|
|
204
143
|
|
|
@@ -220,8 +159,8 @@ It is also possible to pack/unpack custom data types using the **ext** type.
|
|
|
220
159
|
... return ExtType(code, data)
|
|
221
160
|
...
|
|
222
161
|
>>> data = array.array('d', [1.2, 3.4])
|
|
223
|
-
>>> packed = msgpack.packb(data, default=default
|
|
224
|
-
>>> unpacked = msgpack.unpackb(packed, ext_hook=ext_hook
|
|
162
|
+
>>> packed = msgpack.packb(data, default=default)
|
|
163
|
+
>>> unpacked = msgpack.unpackb(packed, ext_hook=ext_hook)
|
|
225
164
|
>>> data == unpacked
|
|
226
165
|
True
|
|
227
166
|
```
|
|
@@ -239,7 +178,7 @@ in a map, can be unpacked or skipped individually.
|
|
|
239
178
|
|
|
240
179
|
## Notes
|
|
241
180
|
|
|
242
|
-
### string and binary type
|
|
181
|
+
### string and binary type in old msgpack spec
|
|
243
182
|
|
|
244
183
|
Early versions of msgpack didn't distinguish string and binary types.
|
|
245
184
|
The type for representing both string and binary types was named **raw**.
|
|
@@ -292,3 +231,41 @@ You can use `gc.disable()` when unpacking large message.
|
|
|
292
231
|
List is the default sequence type of Python.
|
|
293
232
|
But tuple is lighter than list.
|
|
294
233
|
You can use `use_list=False` while unpacking when performance is important.
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
## Major breaking changes in the history
|
|
237
|
+
|
|
238
|
+
### msgpack 0.5
|
|
239
|
+
|
|
240
|
+
Package name on PyPI was changed from `msgpack-python` to `msgpack` from 0.5.
|
|
241
|
+
|
|
242
|
+
When upgrading from msgpack-0.4 or earlier, do `pip uninstall msgpack-python` before
|
|
243
|
+
`pip install -U msgpack`.
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
### msgpack 1.0
|
|
247
|
+
|
|
248
|
+
* Python 2 support
|
|
249
|
+
|
|
250
|
+
* The extension module does not support Python 2 anymore.
|
|
251
|
+
The pure Python implementation (`msgpack.fallback`) is used for Python 2.
|
|
252
|
+
|
|
253
|
+
* msgpack 1.0.6 drops official support of Python 2.7, as pip and
|
|
254
|
+
GitHub Action (setup-python) no longer support Python 2.7.
|
|
255
|
+
|
|
256
|
+
* Packer
|
|
257
|
+
|
|
258
|
+
* Packer uses `use_bin_type=True` by default.
|
|
259
|
+
Bytes are encoded in bin type in msgpack.
|
|
260
|
+
* The `encoding` option is removed. UTF-8 is used always.
|
|
261
|
+
|
|
262
|
+
* Unpacker
|
|
263
|
+
|
|
264
|
+
* Unpacker uses `raw=False` by default. It assumes str types are valid UTF-8 string
|
|
265
|
+
and decode them to Python str (unicode) object.
|
|
266
|
+
* `encoding` option is removed. You can use `raw=True` to support old format (e.g. unpack into bytes, not str).
|
|
267
|
+
* Default value of `max_buffer_size` is changed from 0 to 100 MiB to avoid DoS attack.
|
|
268
|
+
You need to pass `max_buffer_size=0` if you have large but safe data.
|
|
269
|
+
* Default value of `strict_map_key` is changed to True to avoid hashdos.
|
|
270
|
+
You need to pass `strict_map_key=False` if you have data which contain map keys
|
|
271
|
+
which type is not bytes or str.
|
|
@@ -10,53 +10,6 @@ It lets you exchange data among multiple languages like JSON.
|
|
|
10
10
|
But it's faster and smaller.
|
|
11
11
|
This package provides CPython bindings for reading and writing MessagePack data.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
## Very important notes for existing users
|
|
15
|
-
|
|
16
|
-
### PyPI package name
|
|
17
|
-
|
|
18
|
-
Package name on PyPI was changed from `msgpack-python` to `msgpack` from 0.5.
|
|
19
|
-
|
|
20
|
-
When upgrading from msgpack-0.4 or earlier, do `pip uninstall msgpack-python` before
|
|
21
|
-
`pip install -U msgpack`.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### Compatibility with the old format
|
|
25
|
-
|
|
26
|
-
You can use `use_bin_type=False` option to pack `bytes`
|
|
27
|
-
object into raw type in the old msgpack spec, instead of bin type in new msgpack spec.
|
|
28
|
-
|
|
29
|
-
You can unpack old msgpack format using `raw=True` option.
|
|
30
|
-
It unpacks str (raw) type in msgpack into Python bytes.
|
|
31
|
-
|
|
32
|
-
See note below for detail.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### Major breaking changes in msgpack 1.0
|
|
36
|
-
|
|
37
|
-
* Python 2
|
|
38
|
-
|
|
39
|
-
* The extension module does not support Python 2 anymore.
|
|
40
|
-
The pure Python implementation (`msgpack.fallback`) is used for Python 2.
|
|
41
|
-
|
|
42
|
-
* Packer
|
|
43
|
-
|
|
44
|
-
* `use_bin_type=True` by default. bytes are encoded in bin type in msgpack.
|
|
45
|
-
**If you are still using Python 2, you must use unicode for all string types.**
|
|
46
|
-
You can use `use_bin_type=False` to encode into old msgpack format.
|
|
47
|
-
* `encoding` option is removed. UTF-8 is used always.
|
|
48
|
-
|
|
49
|
-
* Unpacker
|
|
50
|
-
|
|
51
|
-
* `raw=False` by default. It assumes str types are valid UTF-8 string
|
|
52
|
-
and decode them to Python str (unicode) object.
|
|
53
|
-
* `encoding` option is removed. You can use `raw=True` to support old format.
|
|
54
|
-
* Default value of `max_buffer_size` is changed from 0 to 100 MiB.
|
|
55
|
-
* Default value of `strict_map_key` is changed to True to avoid hashdos.
|
|
56
|
-
You need to pass `strict_map_key=False` if you have data which contain map keys
|
|
57
|
-
which type is not bytes or str.
|
|
58
|
-
|
|
59
|
-
|
|
60
13
|
## Install
|
|
61
14
|
|
|
62
15
|
```
|
|
@@ -65,12 +18,9 @@ $ pip install msgpack
|
|
|
65
18
|
|
|
66
19
|
### Pure Python implementation
|
|
67
20
|
|
|
68
|
-
The extension module in msgpack (`msgpack._cmsgpack`) does not support
|
|
69
|
-
Python 2 and PyPy.
|
|
70
|
-
|
|
71
|
-
But msgpack provides a pure Python implementation (`msgpack.fallback`)
|
|
72
|
-
for PyPy and Python 2.
|
|
21
|
+
The extension module in msgpack (`msgpack._cmsgpack`) does not support PyPy.
|
|
73
22
|
|
|
23
|
+
But msgpack provides a pure Python implementation (`msgpack.fallback`) for PyPy.
|
|
74
24
|
|
|
75
25
|
|
|
76
26
|
### Windows
|
|
@@ -82,10 +32,6 @@ Without extension, using pure Python implementation on CPython runs slowly.
|
|
|
82
32
|
|
|
83
33
|
## How to use
|
|
84
34
|
|
|
85
|
-
NOTE: In examples below, I use `raw=False` and `use_bin_type=True` for users
|
|
86
|
-
using msgpack < 1.0. These options are default from msgpack 1.0 so you can omit them.
|
|
87
|
-
|
|
88
|
-
|
|
89
35
|
### One-shot pack & unpack
|
|
90
36
|
|
|
91
37
|
Use `packb` for packing and `unpackb` for unpacking.
|
|
@@ -97,23 +43,13 @@ msgpack provides `dumps` and `loads` as an alias for compatibility with
|
|
|
97
43
|
|
|
98
44
|
```pycon
|
|
99
45
|
>>> import msgpack
|
|
100
|
-
>>> msgpack.packb([1, 2, 3]
|
|
46
|
+
>>> msgpack.packb([1, 2, 3])
|
|
101
47
|
'\x93\x01\x02\x03'
|
|
102
|
-
>>> msgpack.unpackb(_
|
|
48
|
+
>>> msgpack.unpackb(_)
|
|
103
49
|
[1, 2, 3]
|
|
104
50
|
```
|
|
105
51
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```pycon
|
|
109
|
-
>>> msgpack.unpackb(b'\x93\x01\x02\x03', use_list=False, raw=False)
|
|
110
|
-
(1, 2, 3)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
You should always specify the `use_list` keyword argument for backward compatibility.
|
|
114
|
-
See performance issues relating to `use_list option`_ below.
|
|
115
|
-
|
|
116
|
-
Read the docstring for other options.
|
|
52
|
+
Read the docstring for options.
|
|
117
53
|
|
|
118
54
|
|
|
119
55
|
### Streaming unpacking
|
|
@@ -127,11 +63,11 @@ from io import BytesIO
|
|
|
127
63
|
|
|
128
64
|
buf = BytesIO()
|
|
129
65
|
for i in range(100):
|
|
130
|
-
buf.write(msgpack.packb(i
|
|
66
|
+
buf.write(msgpack.packb(i))
|
|
131
67
|
|
|
132
68
|
buf.seek(0)
|
|
133
69
|
|
|
134
|
-
unpacker = msgpack.Unpacker(buf
|
|
70
|
+
unpacker = msgpack.Unpacker(buf)
|
|
135
71
|
for unpacked in unpacker:
|
|
136
72
|
print(unpacked)
|
|
137
73
|
```
|
|
@@ -162,14 +98,17 @@ def encode_datetime(obj):
|
|
|
162
98
|
return obj
|
|
163
99
|
|
|
164
100
|
|
|
165
|
-
packed_dict = msgpack.packb(useful_dict, default=encode_datetime
|
|
166
|
-
this_dict_again = msgpack.unpackb(packed_dict, object_hook=decode_datetime
|
|
101
|
+
packed_dict = msgpack.packb(useful_dict, default=encode_datetime)
|
|
102
|
+
this_dict_again = msgpack.unpackb(packed_dict, object_hook=decode_datetime)
|
|
167
103
|
```
|
|
168
104
|
|
|
169
105
|
`Unpacker`'s `object_hook` callback receives a dict; the
|
|
170
106
|
`object_pairs_hook` callback may instead be used to receive a list of
|
|
171
107
|
key-value pairs.
|
|
172
108
|
|
|
109
|
+
NOTE: msgpack can encode datetime with tzinfo into standard ext type for now.
|
|
110
|
+
See `datetime` option in `Packer` docstring.
|
|
111
|
+
|
|
173
112
|
|
|
174
113
|
### Extended types
|
|
175
114
|
|
|
@@ -191,8 +130,8 @@ It is also possible to pack/unpack custom data types using the **ext** type.
|
|
|
191
130
|
... return ExtType(code, data)
|
|
192
131
|
...
|
|
193
132
|
>>> data = array.array('d', [1.2, 3.4])
|
|
194
|
-
>>> packed = msgpack.packb(data, default=default
|
|
195
|
-
>>> unpacked = msgpack.unpackb(packed, ext_hook=ext_hook
|
|
133
|
+
>>> packed = msgpack.packb(data, default=default)
|
|
134
|
+
>>> unpacked = msgpack.unpackb(packed, ext_hook=ext_hook)
|
|
196
135
|
>>> data == unpacked
|
|
197
136
|
True
|
|
198
137
|
```
|
|
@@ -210,7 +149,7 @@ in a map, can be unpacked or skipped individually.
|
|
|
210
149
|
|
|
211
150
|
## Notes
|
|
212
151
|
|
|
213
|
-
### string and binary type
|
|
152
|
+
### string and binary type in old msgpack spec
|
|
214
153
|
|
|
215
154
|
Early versions of msgpack didn't distinguish string and binary types.
|
|
216
155
|
The type for representing both string and binary types was named **raw**.
|
|
@@ -263,3 +202,41 @@ You can use `gc.disable()` when unpacking large message.
|
|
|
263
202
|
List is the default sequence type of Python.
|
|
264
203
|
But tuple is lighter than list.
|
|
265
204
|
You can use `use_list=False` while unpacking when performance is important.
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
## Major breaking changes in the history
|
|
208
|
+
|
|
209
|
+
### msgpack 0.5
|
|
210
|
+
|
|
211
|
+
Package name on PyPI was changed from `msgpack-python` to `msgpack` from 0.5.
|
|
212
|
+
|
|
213
|
+
When upgrading from msgpack-0.4 or earlier, do `pip uninstall msgpack-python` before
|
|
214
|
+
`pip install -U msgpack`.
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
### msgpack 1.0
|
|
218
|
+
|
|
219
|
+
* Python 2 support
|
|
220
|
+
|
|
221
|
+
* The extension module does not support Python 2 anymore.
|
|
222
|
+
The pure Python implementation (`msgpack.fallback`) is used for Python 2.
|
|
223
|
+
|
|
224
|
+
* msgpack 1.0.6 drops official support of Python 2.7, as pip and
|
|
225
|
+
GitHub Action (setup-python) no longer support Python 2.7.
|
|
226
|
+
|
|
227
|
+
* Packer
|
|
228
|
+
|
|
229
|
+
* Packer uses `use_bin_type=True` by default.
|
|
230
|
+
Bytes are encoded in bin type in msgpack.
|
|
231
|
+
* The `encoding` option is removed. UTF-8 is used always.
|
|
232
|
+
|
|
233
|
+
* Unpacker
|
|
234
|
+
|
|
235
|
+
* Unpacker uses `raw=False` by default. It assumes str types are valid UTF-8 string
|
|
236
|
+
and decode them to Python str (unicode) object.
|
|
237
|
+
* `encoding` option is removed. You can use `raw=True` to support old format (e.g. unpack into bytes, not str).
|
|
238
|
+
* Default value of `max_buffer_size` is changed from 0 to 100 MiB to avoid DoS attack.
|
|
239
|
+
You need to pass `max_buffer_size=0` if you have large but safe data.
|
|
240
|
+
* Default value of `strict_map_key` is changed to True to avoid hashdos.
|
|
241
|
+
You need to pass `strict_map_key=False` if you have data which contain map keys
|
|
242
|
+
which type is not bytes or str.
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
from .ext import ExtType, Timestamp
|
|
3
|
-
|
|
1
|
+
# ruff: noqa: F401
|
|
4
2
|
import os
|
|
5
3
|
|
|
4
|
+
from .exceptions import * # noqa: F403
|
|
5
|
+
from .ext import ExtType, Timestamp
|
|
6
6
|
|
|
7
|
-
version = (1,
|
|
8
|
-
__version__ = "1.0
|
|
7
|
+
version = (1, 1, 0)
|
|
8
|
+
__version__ = "1.1.0"
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
if os.environ.get("MSGPACK_PUREPYTHON"):
|
|
12
|
-
from .fallback import Packer,
|
|
12
|
+
from .fallback import Packer, Unpacker, unpackb
|
|
13
13
|
else:
|
|
14
14
|
try:
|
|
15
|
-
from ._cmsgpack import Packer,
|
|
15
|
+
from ._cmsgpack import Packer, Unpacker, unpackb
|
|
16
16
|
except ImportError:
|
|
17
|
-
from .fallback import Packer,
|
|
17
|
+
from .fallback import Packer, Unpacker, unpackb
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def pack(o, stream, **kwargs):
|