We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 95c8be5 commit bcf89c7Copy full SHA for bcf89c7
1 file changed
README.md
@@ -119,15 +119,15 @@ It is also possible to pack/unpack custom data types using the **ext** type.
119
>>> import array
120
>>> def default(obj):
121
... if isinstance(obj, array.array) and obj.typecode == 'd':
122
-... return msgpack.ExtType(42, obj.tostring())
+... return msgpack.ExtType(42, obj.tobytes())
123
... raise TypeError("Unknown type: %r" % (obj,))
124
...
125
>>> def ext_hook(code, data):
126
... if code == 42:
127
... a = array.array('d')
128
-... a.fromstring(data)
+... a.frombytes(data)
129
... return a
130
-... return ExtType(code, data)
+... return msgpack.ExtType(code, data)
131
132
>>> data = array.array('d', [1.2, 3.4])
133
>>> packed = msgpack.packb(data, default=default)
0 commit comments