Skip to content

Commit 4834232

Browse files
committed
Fix mechanism used to check for invalid whence in fs.zipfs
1 parent 8b72697 commit 4834232

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/zipfs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,14 @@ def seek(self, offset, whence=Seek.set):
158158
"""
159159
_whence = int(whence)
160160
_pos = self.tell()
161-
if _whence == Seek.current or _whence == Seek.set:
161+
if _whence == Seek.set:
162+
if offset < 0:
163+
raise ValueError("Negative seek position {}".format(offset))
164+
elif _whence == Seek.current:
162165
if _pos + offset < 0:
163166
raise ValueError("Negative seek position {}".format(offset))
164167
elif _whence == Seek.end:
165-
if _pos + offset > 0:
168+
if offset > 0:
166169
raise ValueError("Positive seek position {}".format(offset))
167170
else:
168171
raise ValueError(

0 commit comments

Comments
 (0)