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.
@@ -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