From 683333955a05a31da5f0b2ca1b3bffb9962fb4b2 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Fri, 22 May 2015 11:16:47 -0400 Subject: Issue 24237: Raise PendingDeprecationWarning per PEP 479 Raise PendingDeprecationWarning when generator raises StopIteration and no __future__ import is used. Fix offenders in the stdlib and tests. See also issue 22906. Thanks to Nick Coghlan and Berker Peksag for reviews. --- Lib/difflib.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Lib/difflib.py') diff --git a/Lib/difflib.py b/Lib/difflib.py index aa98436ce3..22d9145a07 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -1582,7 +1582,10 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None, while True: # Collecting lines of text until we have a from/to pair while (len(fromlines)==0 or len(tolines)==0): - from_line, to_line, found_diff = next(line_iterator) + try: + from_line, to_line, found_diff = next(line_iterator) + except StopIteration: + return if from_line is not None: fromlines.append((from_line,found_diff)) if to_line is not None: @@ -1609,7 +1612,10 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None, index, contextLines = 0, [None]*(context) found_diff = False while(found_diff is False): - from_line, to_line, found_diff = next(line_pair_iterator) + try: + from_line, to_line, found_diff = next(line_pair_iterator) + except StopIteration: + return i = index % context contextLines[i] = (from_line, to_line, found_diff) index += 1 -- cgit v1.2.1