From 7ad8056fa36c5ebee3e25f2b0efb37e9b3644414 Mon Sep 17 00:00:00 2001 From: Max Campos Date: Thu, 29 Jun 2017 15:00:59 -0700 Subject: [PATCH] Fixes #302 -- deprecation warnings when array.tostring() is called on Python 3.3+. --- thriftpy/protocol/compact.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/thriftpy/protocol/compact.py b/thriftpy/protocol/compact.py index 9f49e05..3d11be4 100644 --- a/thriftpy/protocol/compact.py +++ b/thriftpy/protocol/compact.py @@ -58,7 +58,10 @@ def write_varint(trans, n): else: out.append((n & 0xff) | 0x80) n = n >> 7 - data = array.array('B', out).tostring() + + # 3.2+ uses tobytes(). Thriftpy doesn't support Python 3 pre-3.3 + a = array.array('B', out) + data = a.tobytes() if PY3 else a.tostring() if PY3: trans.write(data)