From 2fb1dcbe5e8c8a826e8a9567ffb49295a2402641 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 29 Jun 2018 14:27:21 +0100 Subject: [PATCH] Replace 'raise StopIteration' with 'return' With PEP 479, the behaviour of StopIteration is changing. Raising it to stop a generator is considered incorrect and from Python 3.7 this will cause a RuntimeError. The PEP recommends using the return statement. More details: https://www.python.org/dev/peps/pep-0479/#examples-of-breakage Change-Id: If53f0f4c313a699a4036838ab6035fffa931931b --- troveclient/v1/backups.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/troveclient/v1/backups.py b/troveclient/v1/backups.py index 0ba18e7f..f314fdc2 100644 --- a/troveclient/v1/backups.py +++ b/troveclient/v1/backups.py @@ -243,7 +243,7 @@ class Backups(base.ManagerWithFind): yield the_item m = the_list[-1].id else: - raise StopIteration() + return def execution_list_generator(): yielded = 0 @@ -254,7 +254,7 @@ class Backups(base.ManagerWithFind): loaded=True) yielded += 1 if limit and yielded == limit: - raise StopIteration() + return return list(execution_list_generator())