]> arthur.barton.de Git - bup.git/commitdiff
vfs: import EINVAL for FileReader seek and include size in exception
authorRob Browning <rlb@defaultvalue.org>
Mon, 3 Dec 2018 18:39:20 +0000 (12:39 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 8 Dec 2018 22:10:27 +0000 (16:10 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/vfs.py

index 1e2705c2eef597e2ce833c97d702c979563ca949..124c3f0462a47f6a621e137ee6233ae15f5baead 100644 (file)
@@ -48,7 +48,7 @@ item.coid.
 
 from __future__ import absolute_import, print_function
 from collections import namedtuple
-from errno import ELOOP, ENOENT, ENOTDIR
+from errno import EINVAL, ELOOP, ENOENT, ENOTDIR
 from itertools import chain, dropwhile, groupby, tee
 from random import randrange
 from stat import S_IFDIR, S_IFLNK, S_IFREG, S_ISDIR, S_ISLNK, S_ISREG
@@ -162,10 +162,8 @@ class _FileReader(object):
         return self._size
         
     def seek(self, ofs):
-        if ofs < 0:
-            raise IOError(errno.EINVAL, 'Invalid argument')
-        if ofs > self._compute_size():
-            raise IOError(errno.EINVAL, 'Invalid argument')
+        if ofs < 0 or ofs > self._compute_size():
+            raise IOError(EINVAL, 'Invalid seek offset: %d' % ofs)
         self.ofs = ofs
 
     def tell(self):