From 5a83f744180b782e06b4a534ef956d1e9d6074e9 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 30 Jul 2016 19:42:25 +0200 Subject: [PATCH] RemoteRepository init: always call close on exceptions, fixes #1370 This fixes the cosmetic issue that the cleanup happened in __del__ and caused an AssertionError there. --- borg/remote.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/borg/remote.py b/borg/remote.py index a3a0afe74..e79e46bc7 100644 --- a/borg/remote.py +++ b/borg/remote.py @@ -170,12 +170,12 @@ class RemoteRepository: self.x_fds = [self.stdin_fd, self.stdout_fd, self.stderr_fd] try: - version = self.call('negotiate', RPC_PROTOCOL_VERSION) - except ConnectionClosed: - 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) - try: + try: + version = self.call('negotiate', RPC_PROTOCOL_VERSION) + except ConnectionClosed: + 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) # Because of protocol versions, only send append_only if necessary if append_only: try: