diff options
author | Benoit Foucher <benoit@zeroc.com> | 2013-09-17 11:22:22 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2013-09-17 11:22:22 +0200 |
commit | 0ec6ca2358bbceae6e3bc740e86470df8ffed5c7 (patch) | |
tree | 81b8b93edc233cf1863ad84464596d4aa03bfad1 | |
parent | revert unintended chante to testicedist.py (diff) | |
download | ice-0ec6ca2358bbceae6e3bc740e86470df8ffed5c7.tar.bz2 ice-0ec6ca2358bbceae6e3bc740e86470df8ffed5c7.tar.xz ice-0ec6ca2358bbceae6e3bc740e86470df8ffed5c7.zip |
Better fix for ICE-5426 - use bytearray() instead of xrange/range to create byte array
-rwxr-xr-x | py/demo/Ice/throughput/Client.py | 8 | ||||
-rw-r--r-- | py/test/Ice/exceptions/AllTests.py | 11 | ||||
-rwxr-xr-x | py/test/Ice/exceptions/ServerAMD.py | 8 | ||||
-rw-r--r-- | py/test/Ice/exceptions/TestI.py | 2 |
4 files changed, 5 insertions, 24 deletions
diff --git a/py/demo/Ice/throughput/Client.py b/py/demo/Ice/throughput/Client.py index 48bf1b683f0..5da6fd8d27e 100755 --- a/py/demo/Ice/throughput/Client.py +++ b/py/demo/Ice/throughput/Client.py @@ -47,13 +47,7 @@ class Client(Ice.Application): return 1 throughputOneway = Demo.ThroughputPrx.uncheckedCast(throughput.ice_oneway()) - if sys.version_info[0] == 2: - b = [] - b[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) - b = ['\x00' for x in b] - byteSeq = ''.join(b) - else: - byteSeq = bytes([0 for x in range(0, Demo.ByteSeqSize)]) + byteSeq = bytearray(Demo.ByteSeqSize) stringSeq = [] stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize) diff --git a/py/test/Ice/exceptions/AllTests.py b/py/test/Ice/exceptions/AllTests.py index bbc89a0e0a3..6fadedc2edc 100644 --- a/py/test/Ice/exceptions/AllTests.py +++ b/py/test/Ice/exceptions/AllTests.py @@ -9,12 +9,6 @@ import Ice, Test, threading, sys, array -# -# xrange is not supported with python >= 3.x -# -if sys.version_info[0] >= 3: - xrange = range - def test(b): if not b: raise RuntimeError('test assertion failed') @@ -708,7 +702,7 @@ def allTests(communicator): test(False) try: - thrower.throwMemoryLimitException(array.array('B', (0 for x in xrange(20 * 1024)))) # 20KB + thrower.throwMemoryLimitException(bytearray(20 * 1024)) # 20KB test(False) except Ice.MemoryLimitException: pass @@ -716,8 +710,7 @@ def allTests(communicator): test(False) try: - thrower.end_throwMemoryLimitException( - thrower.begin_throwMemoryLimitException(array.array('B', (0 for x in xrange(20 * 1024))))) # 20KB + thrower.end_throwMemoryLimitException(thrower.begin_throwMemoryLimitException(bytearray(20 * 1024))) # 20KB test(False) except Ice.MemoryLimitException: pass diff --git a/py/test/Ice/exceptions/ServerAMD.py b/py/test/Ice/exceptions/ServerAMD.py index 9e2488222a4..a7bc37a4825 100755 --- a/py/test/Ice/exceptions/ServerAMD.py +++ b/py/test/Ice/exceptions/ServerAMD.py @@ -19,12 +19,6 @@ if not slice_dir: Ice.loadSlice('"-I' + slice_dir + '" TestAMD.ice') import Test -# -# There isn't xrange in python 3.x -# -if sys.version_info.major >= 3: - xrange = range - def test(b): if not b: raise RuntimeError('test assertion failed') @@ -132,7 +126,7 @@ class ThrowerI(Test.Thrower): raise RuntimeError("operation `throwAssertException' not supported") def throwMemoryLimitException_async(self, cb, seq, current=None): - cb.ice_response(array.array('B', (0 for x in xrange(20 * 1024)))) + cb.ice_response(bytearray(20 * 1024)) def throwLocalExceptionIdempotent_async(self, cb, current=None): cb.ice_exception(Ice.TimeoutException()) diff --git a/py/test/Ice/exceptions/TestI.py b/py/test/Ice/exceptions/TestI.py index 401193c05e5..326c57b6ca2 100644 --- a/py/test/Ice/exceptions/TestI.py +++ b/py/test/Ice/exceptions/TestI.py @@ -96,7 +96,7 @@ class ThrowerI(Test.Thrower): raise RuntimeError("operation `throwAssertException' not supported") def throwMemoryLimitException(self, seq, current=None): - return array.array('B', (0 for x in xrange(20 * 1024))) + return bytearray(20 * 1024) def throwLocalExceptionIdempotent(self, current=None): raise Ice.TimeoutException() |