diff --git a/vdirsyncer/sync.py b/vdirsyncer/sync.py index f6b105c..28ae069 100644 --- a/vdirsyncer/sync.py +++ b/vdirsyncer/sync.py @@ -27,11 +27,14 @@ sync_logger = logging.getLogger(__name__) @contextlib.contextmanager def _exclusive_transaction(conn): + c = None try: c = conn.execute('BEGIN EXCLUSIVE TRANSACTION') yield c c.execute('COMMIT') except BaseException: + if c is None: + raise _, e, tb = sys.exc_info() c.execute('ROLLBACK') raise e.with_traceback(tb)