Revert "RuntimeError: generator raised StopIteration"

Hi, The idea is simple: restore the "next" built-in and the "StopIteration" propagation behavior from Python 3.6. I'm using Python 3.7 for a while (as it's the default in Arch Linux), and there's one single backwards incompatible change from Python 3.6 that is breaking the code of some packages from PyPI. The reason is always the same: a "next" called inside a generator function was expected to propagate the StopIteration, but that no longer happens. As an example of something that had been made public (in PyPI), I've tried to run: from articlemeta.client import RestfulClient journals = list(RestfulClient().journals(collection="ecu")) This breaks with "RuntimeError: generator raised StopIteration". I already warned the maintainers of that project, it probably will be fixed. Another example (disclaimer: this time it's a package I've created): a simple "pip install dose" only works on Python<3.7, since some reStructuredText processing functions rely on the StopIteration propagation from calls to "next". I needed this package last saturday for a Coding Dojo, but I had to download the package from the repository and change some stuff before starting the Dojo (during the time reserved for it). I can fix this in the packages I'm maintaining by creating a new "fix_python37_next_runtime_error" decorator to restore the old behavior on every generator function that uses "next" in its body. But I can't do that to all packages from other people, and having to change/monkeypatch imported stuff in order to keep it working in this new Python version is getting annoying already. Perhaps adding a new kwarg to the "next" built-in to choose between a "propagate" default or a "error" alternative would avoid this. -- Danilo J. S. Bellini --------------- "*It is not our business to set up prohibitions, but to arrive at conventions.*" (R. Carnap)

On 09/17/2018 11:06 AM, Danilo J. S. Bellini wrote:
The idea is simple: restore the "next" built-in and the "StopIteration" propagation behavior from Python 3.6.
Unlikely to happen. In 3.6 a deprecation warning started being issued for next inside generators that said it would raise a different exception in 3.7 [1]. -- ~Ethan~ [1] PEP 479: https://docs.python.org/3/whatsnew/3.5.html#whatsnew-pep-479

On 09/17/2018 11:06 AM, Danilo J. S. Bellini wrote:
The idea is simple: restore the "next" built-in and the "StopIteration" propagation behavior from Python 3.6.
Unlikely to happen. In 3.6 a deprecation warning started being issued for next inside generators that said it would raise a different exception in 3.7 [1]. -- ~Ethan~ [1] PEP 479: https://docs.python.org/3/whatsnew/3.5.html#whatsnew-pep-479
participants (2)
-
Danilo J. S. Bellini
-
Ethan Furman