Skip to content

Commit caa43c8

Browse files
authored
README: Fixed python3
Remove old api, use new array api available from python 3.2
1 parent 95c8be5 commit caa43c8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ It is also possible to pack/unpack custom data types using the **ext** type.
119119
>>> import array
120120
>>> def default(obj):
121121
... if isinstance(obj, array.array) and obj.typecode == 'd':
122-
... return msgpack.ExtType(42, obj.tostring())
122+
... return msgpack.ExtType(42, obj.tobytes())
123123
... raise TypeError("Unknown type: %r" % (obj,))
124124
...
125125
>>> def ext_hook(code, data):
126126
... if code == 42:
127127
... a = array.array('d')
128-
... a.fromstring(data)
128+
... a.frombytes(data)
129129
... return a
130-
... return ExtType(code, data)
130+
... return msgpack.ExtType(code, data)
131131
...
132132
>>> data = array.array('d', [1.2, 3.4])
133133
>>> packed = msgpack.packb(data, default=default)

0 commit comments

Comments
 (0)