diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2012-01-11 19:56:12 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2012-01-11 19:56:12 +0000 |
commit | 81145952a4e26ad0ddfd6e4f502a95ee8f4ae4e5 (patch) | |
tree | 1fc3152061e6baeb19f75db81bac1d3867f88c1d | |
parent | 7f236f2dafdce20b6a9e2e8a9433e0ca027588df (diff) | |
download | pysendfile-81145952a4e26ad0ddfd6e4f502a95ee8f4ae4e5.tar.gz |
fix for python 2.5
-rw-r--r-- | test/benchmark.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/test/benchmark.py b/test/benchmark.py index 74961dd..56d86d5 100644 --- a/test/benchmark.py +++ b/test/benchmark.py @@ -45,6 +45,17 @@ BIGFILE = "$testfile1" BIGFILE_SIZE = 1024 * 1024 * 1024 # 1 GB BUFFER_SIZE = 65536 +# python 3 compatibility layer +def b(s): + return bytes(s, 'ascii') if sys.version_info >= (3,) else s + +# python 2.5 compatibility +try: + next +except NameError: + def next(iterator): + return iterator.next() + def print_(s, hilite=False): if hilite: bold = '1' @@ -52,10 +63,6 @@ def print_(s, hilite=False): sys.stdout.write(s + "\n") sys.stdout.flush() -# python 3 compatibility layer -def b(s): - return bytes(s, 'ascii') if sys.version_info >= (3,) else s - def create_file(filename, size): with open(filename, 'wb') as f: bytes = 0 |