From 199f192a65c8b753f5c09cd8c35abcd71131f7a6 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 22 Jul 2017 02:42:12 +0200 Subject: [PATCH] archive: closely wrap next() called from generator lgtm: Calling next() in a generator may cause unintended early termination of an iteration. It seems that lgtm did not detect the more loose wrapping that we used before. --- src/borg/archive.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index aff947bb4..a32d10e51 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -172,11 +172,11 @@ backup_io = BackupIO() def backup_io_iter(iterator): backup_io.op = 'read' while True: - try: - with backup_io: + with backup_io: + try: item = next(iterator) - except StopIteration: - return + except StopIteration: + return yield item