From: Ben Darnell Date: Fri, 30 Dec 2011 22:47:21 +0000 (-0800) Subject: bytearray is a 2.6ism; use array.array("B") instead for 2.5 compatibility. X-Git-Tag: v2.2.0~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b31d8de4c99bad2ba27f97d15dde7adb4e86812;p=thirdparty%2Ftornado.git bytearray is a 2.6ism; use array.array("B") instead for 2.5 compatibility. --- diff --git a/maint/test/websocket/run.sh b/maint/test/websocket/run.sh index 2ca103e46..d11870152 100755 --- a/maint/test/websocket/run.sh +++ b/maint/test/websocket/run.sh @@ -12,15 +12,22 @@ set -e # build/update the virtualenvs tox -.tox/py27/bin/python server.py --port=9001 & +.tox/py25/bin/python server.py --port=9001 & +PY25_SERVER_PID=$! + +.tox/py27/bin/python server.py --port=9002 & PY27_SERVER_PID=$! -.tox/py32/bin/python server.py --port=9002 & +.tox/py32/bin/python server.py --port=9003 & PY32_SERVER_PID=$! sleep 1 -.tox/py27/bin/python ./client.py --servers=Tornado/py27=ws://localhost:9001,Tornado/py32=ws://localhost:9002 "$@" +.tox/py27/bin/python ./client.py --servers=Tornado/py25=ws://localhost:9001,Tornado/py27=ws://localhost:9002,Tornado/py32=ws://localhost:9003 "$@" +kill $PY25_SERVER_PID kill $PY27_SERVER_PID kill $PY32_SERVER_PID +wait + +echo "Tests complete. Output is in ./reports/servers/index.html" \ No newline at end of file diff --git a/maint/test/websocket/tox.ini b/maint/test/websocket/tox.ini index b85d97283..7b374a48b 100644 --- a/maint/test/websocket/tox.ini +++ b/maint/test/websocket/tox.ini @@ -2,7 +2,7 @@ # to install autobahn and deal with 2to3 for the python3 version. # See run.sh for the real test runner. [tox] -envlist = py27, py32 +envlist = py27, py32, py25 setupdir=../../.. [testenv] diff --git a/tornado/websocket.py b/tornado/websocket.py index 3e2310189..ce8e41dd6 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -13,6 +13,7 @@ communication between the browser and server. """ # Author: Jacob Kristhammar, 2010 +import array import functools import hashlib import logging @@ -455,11 +456,11 @@ class WebSocketProtocol8(WebSocketProtocol): self.stream.read_bytes(4, self._on_masking_key); def _on_masking_key(self, data): - self._frame_mask = bytearray(data) + self._frame_mask = array.array("B", data) self.stream.read_bytes(self._frame_length, self._on_frame_data) def _on_frame_data(self, data): - unmasked = bytearray(data) + unmasked = array.array("B", data) for i in xrange(len(data)): unmasked[i] = unmasked[i] ^ self._frame_mask[i % 4] @@ -494,7 +495,7 @@ class WebSocketProtocol8(WebSocketProtocol): self._fragmented_message_buffer = unmasked if self._final_frame: - self._handle_message(opcode, bytes_type(unmasked)) + self._handle_message(opcode, unmasked.tostring()) if not self.client_terminated: self._receive_frame()