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)