Skip to content

Commit 7efb1fe

Browse files
committed
improve compatibility for Python 2
1 parent d9d6797 commit 7efb1fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bencoder.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ def decode_int(bytes x, int f):
2929
f += 1
3030
new_f = x.index(b'e', f)
3131
n = int(x[f:new_f])
32-
if x[f] == ord('-'):
33-
if x[f + 1] == ord('0'):
32+
if x[f] == b'-'[0]:
33+
if x[f + 1] == b'0'[0]:
3434
raise ValueError()
35-
elif x[f] == ord('0') and new_f != f + 1:
35+
elif x[f] == b'0'[0] and new_f != f + 1:
3636
raise ValueError()
3737
return n, new_f + 1
3838

3939

4040
def decode_string(bytes x, int f):
4141
colon = x.index(b':', f)
4242
n = int(x[f:colon])
43-
if x[f] == ord('0') and colon != f + 1:
43+
if x[f] == b'0'[0] and colon != f + 1:
4444
raise ValueError()
4545
colon += 1
4646
return x[colon:colon + n], colon + n

0 commit comments

Comments
 (0)