Skip to content

Commit

Permalink
Fixes Thriftpy#302 -- deprecation warnings when array.tostring() is c…
Browse files Browse the repository at this point in the history
…alled on Python 3.3+.
  • Loading branch information
terwilliger42 committed Jun 29, 2017
1 parent b30e41d commit 7ad8056
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion thriftpy/protocol/compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7ad8056

Please sign in to comment.