From: Rob Browning Date: Mon, 3 Dec 2018 18:39:20 +0000 (-0600) Subject: vfs: import EINVAL for FileReader seek and include size in exception X-Git-Tag: 0.30~46 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=b15fcfdd5b07b05065be889940cf9d16b61aa047;hp=735148ccf8b8a229f9bd43848678e70c78476217 vfs: import EINVAL for FileReader seek and include size in exception Signed-off-by: Rob Browning --- diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index 1e2705c..124c3f0 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -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):