avoid python3 compile errors in python2 only code (shows up during install)
This commit is contained in:
parent
fc8419ec7d
commit
1fb697b48b
1 changed files with 7 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
||||||
# Written by Petru Paler, Uoti Urpala, Ross Cohen and John Hoffman
|
# Written by Petru Paler, Uoti Urpala, Ross Cohen and John Hoffman
|
||||||
# see LICENSE.txt for license information
|
# see LICENSE.txt for license information
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from types import IntType, LongType, StringType, ListType, TupleType, DictType
|
from types import IntType, LongType, StringType, ListType, TupleType, DictType
|
||||||
try:
|
try:
|
||||||
|
@ -102,10 +103,10 @@ def test_bdecode():
|
||||||
assert 0
|
assert 0
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
assert bdecode('i4e') == 4L
|
assert bdecode('i4e') == 4
|
||||||
assert bdecode('i0e') == 0L
|
assert bdecode('i0e') == 0
|
||||||
assert bdecode('i123456789e') == 123456789L
|
assert bdecode('i123456789e') == 123456789
|
||||||
assert bdecode('i-10e') == -10L
|
assert bdecode('i-10e') == -10
|
||||||
try:
|
try:
|
||||||
bdecode('i-0e')
|
bdecode('i-0e')
|
||||||
assert 0
|
assert 0
|
||||||
|
@ -287,7 +288,7 @@ def bencode(x):
|
||||||
try:
|
try:
|
||||||
encode_func[type(x)](x, r)
|
encode_func[type(x)](x, r)
|
||||||
except:
|
except:
|
||||||
print "*** error *** could not encode type %s (value: %s)" % (type(x), x)
|
print("*** error *** could not encode type %s (value: %s)" % (type(x), x))
|
||||||
assert 0
|
assert 0
|
||||||
return ''.join(r)
|
return ''.join(r)
|
||||||
|
|
||||||
|
@ -295,7 +296,7 @@ def test_bencode():
|
||||||
assert bencode(4) == 'i4e'
|
assert bencode(4) == 'i4e'
|
||||||
assert bencode(0) == 'i0e'
|
assert bencode(0) == 'i0e'
|
||||||
assert bencode(-10) == 'i-10e'
|
assert bencode(-10) == 'i-10e'
|
||||||
assert bencode(12345678901234567890L) == 'i12345678901234567890e'
|
assert bencode(12345678901234567890) == 'i12345678901234567890e'
|
||||||
assert bencode('') == '0:'
|
assert bencode('') == '0:'
|
||||||
assert bencode('abc') == '3:abc'
|
assert bencode('abc') == '3:abc'
|
||||||
assert bencode('1234567890') == '10:1234567890'
|
assert bencode('1234567890') == '10:1234567890'
|
||||||
|
|
Loading…
Reference in a new issue