mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
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.
This commit is contained in:
parent
e79ec70801
commit
683333955a
5 changed files with 78 additions and 29 deletions
|
|
@ -454,7 +454,8 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
|
|||
with cm():
|
||||
raise StopIteration("from with")
|
||||
|
||||
self.assertRaises(StopIteration, shouldThrow)
|
||||
with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
|
||||
self.assertRaises(StopIteration, shouldThrow)
|
||||
|
||||
def testRaisedStopIteration2(self):
|
||||
# From bug 1462485
|
||||
|
|
@ -481,7 +482,8 @@ class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
|
|||
with cm():
|
||||
raise next(iter([]))
|
||||
|
||||
self.assertRaises(StopIteration, shouldThrow)
|
||||
with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
|
||||
self.assertRaises(StopIteration, shouldThrow)
|
||||
|
||||
def testRaisedGeneratorExit1(self):
|
||||
# From bug 1462485
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue