From caa43c8ab29343e3b351ea9b8a96c6b1a0754832 Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Sat, 25 Apr 2026 12:15:46 +0200 Subject: [PATCH] README: Fixed python3 Remove old api, use new array api available from python 3.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f063242..223742dd 100644 --- a/README.md +++ b/README.md @@ -119,15 +119,15 @@ It is also possible to pack/unpack custom data types using the **ext** type. >>> import array >>> def default(obj): ... if isinstance(obj, array.array) and obj.typecode == 'd': -... return msgpack.ExtType(42, obj.tostring()) +... return msgpack.ExtType(42, obj.tobytes()) ... raise TypeError("Unknown type: %r" % (obj,)) ... >>> def ext_hook(code, data): ... if code == 42: ... a = array.array('d') -... a.fromstring(data) +... a.frombytes(data) ... return a -... return ExtType(code, data) +... return msgpack.ExtType(code, data) ... >>> data = array.array('d', [1.2, 3.4]) >>> packed = msgpack.packb(data, default=default)