classification
Title: "RuntimeError: generator raised StopIteration" in difflib.mdiff
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Jeff.Kaufman, rhettinger
Priority: normal Keywords: patch

Created on 2018-04-04 15:18 by Jeff.Kaufman, last changed 2018-04-05 19:23 by rhettinger. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6381 merged rhettinger, 2018-04-05 06:59
PR 6390 merged miss-islington, 2018-04-05 18:21
PR 6391 merged miss-islington, 2018-04-05 18:22
Messages (5)
msg314936 - (view) Author: Jeff Kaufman (Jeff.Kaufman) Date: 2018-04-04 15:18
With python built at HEAD (c51d8c9b) and at 3.7b3 (fcd4e03e08) the code:

    import difflib
    for fromdata, todata, flag in difflib._mdiff(
        ["2"], ["3"], 1):
      pass

produces:

    Traceback (most recent call last):
      File "/home/jefftk/cpython/Lib/difflib.py", line 1638, in _mdiff
        from_line, to_line, found_diff = next(line_pair_iterator)
    StopIteration

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "/home/jefftk/icdiff/repro.py", line 3, in <module>
        ["2"], ["3"], 1):
    RuntimeError: generator raised StopIteration

In python 3.5 and 3.6 I don't get an error.

This is probably due to https://bugs.python.org/issue32670 which implements PEP 479, but I this this isn't supposed to happen in library code?
msg314999 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-05 18:19
New changeset 01b731fc2b04744a11e32f93aba8bfb9ddb3dd29 by Raymond Hettinger in branch 'master':
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381)
https://github.com/python/cpython/commit/01b731fc2b04744a11e32f93aba8bfb9ddb3dd29
msg315001 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-05 18:45
New changeset 28c179094bcb7829d184fb3cfb3ef626505b9f77 by Raymond Hettinger (Miss Islington (bot)) in branch '3.7':
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381) (GH-6390)
https://github.com/python/cpython/commit/28c179094bcb7829d184fb3cfb3ef626505b9f77
msg315003 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-05 19:18
New changeset 8da15f09458fd4f4fe341861e41723892b25a11b by Raymond Hettinger (Miss Islington (bot)) in branch '3.6':
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381) (GH-6391)
https://github.com/python/cpython/commit/8da15f09458fd4f4fe341861e41723892b25a11b
msg315004 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-05 19:23
Thanks for timely report.  I appreciate you exercising the beta release to shake out bugs.
History
Date User Action Args
2018-04-05 19:23:50rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg315004

stage: patch review -> resolved
2018-04-05 19:18:04rhettingersetmessages: + msg315003
2018-04-05 18:45:36rhettingersetmessages: + msg315001
2018-04-05 18:22:10miss-islingtonsetpull_requests: + pull_request6099
2018-04-05 18:21:25miss-islingtonsetpull_requests: + pull_request6098
2018-04-05 18:19:59rhettingersetmessages: + msg314999
2018-04-05 07:02:07rhettingersetversions: + Python 3.6, Python 3.8
2018-04-05 06:59:07rhettingersetkeywords: + patch
stage: patch review
pull_requests: + pull_request6091
2018-04-05 06:25:43rhettingersetassignee: rhettinger

nosy: + rhettinger
2018-04-04 15:18:24Jeff.Kaufmancreate