From 93cb81991a21eabd518a33aba1675ebcd216379c Mon Sep 17 00:00:00 2001 From: Edward Makhlin Date: Sat, 4 Feb 2017 01:21:49 +0300 Subject: [PATCH] Fixed accidental StopIteration bubbling in RecordCollection.__iter__ For more info check this PEP: https://www.python.org/dev/peps/pep-0479/ --- records.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/records.py b/records.py index 7652c81..c6861be 100644 --- a/records.py +++ b/records.py @@ -118,7 +118,11 @@ class RecordCollection(object): yield self[i] else: # Throws StopIteration when done. - yield next(self) + # Prevent StopIteration bubbling from generator, following https://www.python.org/dev/peps/pep-0479/ + try: + yield next(self) + except StopIteration: + return i += 1