diff -r 5873cfb42ebe Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst Tue Feb 02 17:04:56 2016 -0600 +++ b/Doc/whatsnew/3.6.rst Sun Feb 07 11:12:50 2016 +0530 @@ -217,6 +217,15 @@ (Contributed by Rose Ames in :issue:`25791`.) +Deprecated Python Behavior +-------------------------- + +* Raising the :exc:`StopIteration` exception inside a generator will now generate a + :exc:`DeprecationWarning`and will trigger a :exc:`RuntimeError` in Python 3.7. + See :ref:`PEP 479: Change StopIteration handling inside generators ` + for details. + + Removed ======= diff -r 5873cfb42ebe Lib/test/test_contextlib.py --- a/Lib/test/test_contextlib.py Tue Feb 02 17:04:56 2016 -0600 +++ b/Lib/test/test_contextlib.py Sun Feb 07 11:12:50 2016 +0530 @@ -89,7 +89,7 @@ def woohoo(): yield try: - with self.assertWarnsRegex(PendingDeprecationWarning, + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): with woohoo(): raise stop_exc diff -r 5873cfb42ebe Lib/test/test_generators.py --- a/Lib/test/test_generators.py Tue Feb 02 17:04:56 2016 -0600 +++ b/Lib/test/test_generators.py Sun Feb 07 11:12:50 2016 +0530 @@ -245,11 +245,11 @@ yield with self.assertRaises(StopIteration), \ - self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + self.assertWarnsRegex(DeprecationWarning, "StopIteration"): next(gen()) - with self.assertRaisesRegex(PendingDeprecationWarning, + with self.assertRaisesRegex(DeprecationWarning, "generator .* raised StopIteration"), \ warnings.catch_warnings(): @@ -268,7 +268,7 @@ g = f() self.assertEqual(next(g), 1) - with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): with self.assertRaises(StopIteration): next(g) diff -r 5873cfb42ebe Lib/test/test_with.py --- a/Lib/test/test_with.py Tue Feb 02 17:04:56 2016 -0600 +++ b/Lib/test/test_with.py Sun Feb 07 11:12:50 2016 +0530 @@ -454,7 +454,7 @@ with cm(): raise StopIteration("from with") - with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): self.assertRaises(StopIteration, shouldThrow) def testRaisedStopIteration2(self): @@ -482,7 +482,7 @@ with cm(): raise next(iter([])) - with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): self.assertRaises(StopIteration, shouldThrow) def testRaisedGeneratorExit1(self): diff -r 5873cfb42ebe Objects/genobject.c --- a/Objects/genobject.c Tue Feb 02 17:04:56 2016 -0600 +++ b/Objects/genobject.c Sun Feb 07 11:12:50 2016 +0530 @@ -178,7 +178,7 @@ /* Pop the exception before issuing a warning. */ PyErr_Fetch(&exc, &val, &tb); - if (PyErr_WarnFormat(PyExc_PendingDeprecationWarning, 1, + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "generator '%.50S' raised StopIteration", gen->gi_qualname)) { /* Warning was converted to an error. */