Skip to content

Commit ebea06e

Browse files
authored
Merge pull request #29 from kaitai-io/patch-seek2
relative seek(-1,CUR) instead of seek(tell()-1)
2 parents 5dfb881 + 873dabb commit ebea06e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kaitaistruct.py

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

66
PY2 = sys.version_info[0] == 2
77

@@ -71,7 +71,7 @@ def is_eof(self):
7171
if t == b'':
7272
return True
7373
else:
74-
io.seek(io.tell() - 1)
74+
io.seek(-1, SEEK_CUR)
7575
return False
7676

7777
def seek(self, n):
@@ -88,7 +88,7 @@ def size(self):
8888
# Remember our current position
8989
cur_pos = io.tell()
9090
# Seek to the end of the File object
91-
io.seek(0, 2)
91+
io.seek(0, SEEK_END)
9292
# Remember position, which is equal to the full length
9393
full_size = io.tell()
9494
# Seek back to the current position
@@ -287,7 +287,7 @@ def read_bytes_term(self, term, include_term, consume_term, eos_error):
287287
if include_term:
288288
r += c
289289
if not consume_term:
290-
self._io.seek(self._io.tell() - 1)
290+
self._io.seek(-1, SEEK_CUR)
291291
return r
292292
else:
293293
r += c

0 commit comments

Comments
 (0)