summaryrefslogtreecommitdiffstats
path: root/QMTest
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-29 14:21:04 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-03-29 14:21:04 (GMT)
commit238a7bdb01614c5d6b81fdebadd069bc40a61d23 (patch)
treede2e680e944eb3c51fe1ba93714beba4605b18f4 /QMTest
parent7adebb06bb6055345cc584377159d8052ea39e1b (diff)
downloadSCons-238a7bdb01614c5d6b81fdebadd069bc40a61d23.zip
SCons-238a7bdb01614c5d6b81fdebadd069bc40a61d23.tar.gz
SCons-238a7bdb01614c5d6b81fdebadd069bc40a61d23.tar.bz2
http://scons.tigris.org/issues/show_bug.cgi?id=2345
The 'buffer' fixer simply replaces 'buffer( ... )' with 'memoryview( ... )', which is incorrect for our cases, so these changes had to be done by hand and a forward-compatibility class added. The 'xrange' fixer was applied. Manual changes were minimal: a few case in test strings and one use of 'range' as an identifer in the same scope as where 'xrange' was converted to 'range'. The "sets15" compat function, which provided backward compatibility for Python versions prior to 2.2, was removed as no longer needed.
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/TestCmd.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index a7f97d7..0139b29 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -231,6 +231,21 @@ import time
import traceback
import UserList
+try:
+ # pre-2.7 doesn't have the memoryview() built-in
+ memoryview
+except NameError:
+ class memoryview:
+ from types import SliceType
+ def __init__(self, obj):
+ # wrapping buffer in () keeps the fixer from changing it
+ self.obj = (buffer)(obj)
+ def __getitem__(self, indx):
+ if isinstance(indx, self.SliceType):
+ return self.obj[indx.start:indx.stop]
+ else:
+ return self.obj[indx]
+
__all__ = [
'diff_re',
'fail_test',
@@ -809,13 +824,12 @@ def recv_some(p, t=.1, e=1, tr=5, stderr=0):
time.sleep(max((x-time.time())/tr, 0))
return ''.join(y)
-# TODO(3.0: rewrite to use memoryview()
def send_all(p, data):
while len(data):
sent = p.send(data)
if sent is None:
raise Exception(disconnect_message)
- data = buffer(data, sent)
+ data = memoryview(data)[sent:]