Fixes #302 -- deprecation warnings when array.tostring() is called on Python 3.3+#303
Fixes #302 -- deprecation warnings when array.tostring() is called on Python 3.3+#303terwilliger42 wants to merge 1 commit intoThriftpy:developfrom
Conversation
…alled on Python 3.3+.
|
Not sure why this fails Travis for Python 2.6, but don't think it has anything to do with my change. |
|
|
||
| # 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() |
There was a problem hiding this comment.
I'd recommend doing the check once at the top of the file instead of once per call:
if PY3:
tobytes = array.tobytes
else:
tobytes = array.tostring
...
data = tobytes(a)
...
That said, I don't have merge writes - so take suggestions with a grain of salt =u)
There was a problem hiding this comment.
That's a good idea, thanks @wvonnegut. If one of the maintainers would prefer it that way, I'd be happy to change it, just let me know.
|
Would be awesome if someone merged it. My logs are rather unreadable because of tons of deprecation warnings. :/ |
|
@michcio1234 FYI: You can use Python's 'warnings' module to suppress these messages. Here's what we've done in the interim. This disables this specific warning only within the context manager. |
|
Thriftpy was not supported any more, and it already be resolved in thriftpy2, thanks! |
Fixes #302; calls appropriate array.tobytes / array.tostring depending on Python version.