Skip to content

Commit 3c1a982

Browse files
committed
2 parents 1aaa4c2 + ebea06e commit 3c1a982

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

kaitaistruct.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import itertools
22
import sys
33
import struct
4-
from struct import unpack
5-
from io import BytesIO # noqa
4+
from io import BytesIO, SEEK_CUR, SEEK_END # noqa
65

76
PY2 = sys.version_info[0] == 2
87

@@ -72,7 +71,7 @@ def is_eof(self):
7271
if t == b'':
7372
return True
7473
else:
75-
io.seek(io.tell() - 1)
74+
io.seek(-1, SEEK_CUR)
7675
return False
7776

7877
def seek(self, n):
@@ -89,7 +88,7 @@ def size(self):
8988
# Remember our current position
9089
cur_pos = io.tell()
9190
# Seek to the end of the File object
92-
io.seek(0, 2)
91+
io.seek(0, SEEK_END)
9392
# Remember position, which is equal to the full length
9493
full_size = io.tell()
9594
# Seek back to the current position
@@ -288,7 +287,7 @@ def read_bytes_term(self, term, include_term, consume_term, eos_error):
288287
if include_term:
289288
r += c
290289
if not consume_term:
291-
self._io.seek(self._io.tell() - 1)
290+
self._io.seek(-1, SEEK_CUR)
292291
return r
293292
else:
294293
r += c

0 commit comments

Comments
 (0)