diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-22 15:16:47 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-22 15:16:47 (GMT) |
commit | 683333955a05a31da5f0b2ca1b3bffb9962fb4b2 (patch) | |
tree | 236016d773133c19e57c14fc69144e46a586549d /Lib/difflib.py | |
parent | e79ec70801e410de9c3110ffe78f98e08114ae16 (diff) | |
download | cpython-683333955a05a31da5f0b2ca1b3bffb9962fb4b2.zip cpython-683333955a05a31da5f0b2ca1b3bffb9962fb4b2.tar.gz cpython-683333955a05a31da5f0b2ca1b3bffb9962fb4b2.tar.bz2 |
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.
Diffstat (limited to 'Lib/difflib.py')
-rw-r--r-- | Lib/difflib.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py index aa98436..22d9145 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 |