diff --git a/borg/archive.py b/borg/archive.py index ca653ee8e..5ece57240 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -292,7 +292,7 @@ Number of files: {0.stats.nfiles}'''.format(self) else: os.unlink(path) except UnicodeEncodeError: - raise self.IncompatibleFilesystemEncodingError(path, sys.getfilesystemencoding()) + raise self.IncompatibleFilesystemEncodingError(path, sys.getfilesystemencoding()) from None except OSError: pass mode = item[b'mode'] @@ -332,7 +332,7 @@ Number of files: {0.stats.nfiles}'''.format(self) try: os.symlink(source, path) except UnicodeEncodeError: - raise self.IncompatibleFilesystemEncodingError(source, sys.getfilesystemencoding()) + raise self.IncompatibleFilesystemEncodingError(source, sys.getfilesystemencoding()) from None self.restore_attrs(path, item, symlink=True) elif stat.S_ISFIFO(mode): if not os.path.exists(os.path.dirname(path)): diff --git a/borg/cache.py b/borg/cache.py index feffc1fd2..707ad963b 100644 --- a/borg/cache.py +++ b/borg/cache.py @@ -136,7 +136,7 @@ Chunk index: {0.total_unique_chunks:20d} {0.total_chunks:20d}""" raise Exception('%s has unexpected cache version %d (wanted: %d).' % ( config_path, cache_version, wanted_version)) except configparser.NoSectionError as e: - raise Exception('%s does not look like a Borg cache.' % config_path) + raise Exception('%s does not look like a Borg cache.' % config_path) from None self.id = self.config.get('cache', 'repository') self.manifest_id = unhexlify(self.config.get('cache', 'manifest')) self.timestamp = self.config.get('cache', 'timestamp', fallback=None) diff --git a/borg/fuse.py b/borg/fuse.py index 36f761e40..a7c8845b0 100644 --- a/borg/fuse.py +++ b/borg/fuse.py @@ -173,7 +173,7 @@ class FuseOperations(llfuse.Operations): try: return item.get(b'xattrs', {})[name] except KeyError: - raise llfuse.FUSEError(errno.ENODATA) + raise llfuse.FUSEError(errno.ENODATA) from None def _load_pending_archive(self, inode): # Check if this is an archive we need to load diff --git a/borg/helpers.py b/borg/helpers.py index 0a70fc638..43d034ae4 100644 --- a/borg/helpers.py +++ b/borg/helpers.py @@ -777,7 +777,7 @@ def location_validator(archive=None): try: loc = Location(text) except ValueError: - raise argparse.ArgumentTypeError('Invalid location format: "%s"' % text) + raise argparse.ArgumentTypeError('Invalid location format: "%s"' % text) from None if archive is True and not loc.archive: raise argparse.ArgumentTypeError('"%s": No archive specified' % text) elif archive is False and loc.archive: diff --git a/borg/key.py b/borg/key.py index 7ee6305fb..fbcc9d543 100644 --- a/borg/key.py +++ b/borg/key.py @@ -390,7 +390,7 @@ class RepoKey(KeyfileKeyBase): self.repository.load_key() return loc except configparser.NoOptionError: - raise RepoKeyNotFoundError(loc) + raise RepoKeyNotFoundError(loc) from None def get_new_target(self, args): return self.repository diff --git a/borg/locking.py b/borg/locking.py index dd7f96ffc..99d20641b 100644 --- a/borg/locking.py +++ b/borg/locking.py @@ -138,7 +138,7 @@ class ExclusiveLock: if timer.timed_out_or_sleep(): raise LockTimeout(self.path) except OSError as err: - raise LockFailed(self.path, str(err)) + raise LockFailed(self.path, str(err)) from None else: with open(self.unique_name, "wb"): pass diff --git a/borg/remote.py b/borg/remote.py index 1f05d35ee..7de7f9265 100644 --- a/borg/remote.py +++ b/borg/remote.py @@ -159,7 +159,7 @@ class RemoteRepository: try: version = self.call('negotiate', RPC_PROTOCOL_VERSION) except ConnectionClosed: - raise ConnectionClosedWithHint('Is borg working on the server?') + raise ConnectionClosedWithHint('Is borg working on the server?') from None if version != RPC_PROTOCOL_VERSION: raise Exception('Server insisted on using unsupported protocol version %d' % version) self.id = self.call('open', location.path, create, lock_wait, lock) diff --git a/borg/repository.py b/borg/repository.py index 0cf0d934b..4a45fab2f 100644 --- a/borg/repository.py +++ b/borg/repository.py @@ -417,7 +417,7 @@ class Repository: segment, offset = self.index[id_] return self.io.read(segment, offset, id_) except KeyError: - raise self.ObjectNotFound(id_, self.path) + raise self.ObjectNotFound(id_, self.path) from None def get_many(self, ids, is_preloaded=False): for id_ in ids: @@ -446,7 +446,7 @@ class Repository: try: segment, offset = self.index.pop(id) except KeyError: - raise self.ObjectNotFound(id, self.path) + raise self.ObjectNotFound(id, self.path) from None self.segments[segment] -= 1 self.compact.add(segment) segment = self.io.write_delete(id) @@ -628,7 +628,7 @@ class LoggedIO: hdr_tuple = fmt.unpack(header) except struct.error as err: raise IntegrityError('Invalid segment entry header [segment {}, offset {}]: {}'.format( - segment, offset, err)) + segment, offset, err)) from None if fmt is self.put_header_fmt: crc, size, tag, key = hdr_tuple elif fmt is self.header_fmt: diff --git a/borg/testsuite/__init__.py b/borg/testsuite/__init__.py index 67c97789b..1d09be500 100644 --- a/borg/testsuite/__init__.py +++ b/borg/testsuite/__init__.py @@ -144,4 +144,4 @@ class FakeInputs: try: return self.inputs.pop(0) except IndexError: - raise EOFError + raise EOFError from None