From b15fcfdd5b07b05065be889940cf9d16b61aa047 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Mon, 3 Dec 2018 12:39:20 -0600 Subject: [PATCH] vfs: import EINVAL for FileReader seek and include size in exception Signed-off-by: Rob Browning --- lib/bup/vfs.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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): -- 2.39.2