]> granicus.if.org Git - python/commitdiff
Issue #27243: Change PendingDeprecationWarning -> DeprecationWarning.
authorYury Selivanov <yury@magic.io>
Tue, 8 Nov 2016 20:13:07 +0000 (15:13 -0500)
committerYury Selivanov <yury@magic.io>
Tue, 8 Nov 2016 20:13:07 +0000 (15:13 -0500)
As it was agreed in the issue, __aiter__ returning an awaitable
should result in PendingDeprecationWarning in 3.5 and in
DeprecationWarning in 3.6.

Lib/test/test_coroutines.py
Misc/NEWS
Python/ceval.c

index 50e439af45871e65908b0ac424fb0500925267f5..78439a2acae2d8b030375a020e9e0b05376f105d 100644 (file)
@@ -1398,7 +1398,7 @@ class CoroutineTest(unittest.TestCase):
 
         buffer = []
         async def test1():
-            with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
+            with self.assertWarnsRegex(DeprecationWarning, "legacy"):
                 async for i1, i2 in AsyncIter():
                     buffer.append(i1 + i2)
 
@@ -1412,7 +1412,7 @@ class CoroutineTest(unittest.TestCase):
         buffer = []
         async def test2():
             nonlocal buffer
-            with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
+            with self.assertWarnsRegex(DeprecationWarning, "legacy"):
                 async for i in AsyncIter():
                     buffer.append(i[0])
                     if i[0] == 20:
@@ -1431,7 +1431,7 @@ class CoroutineTest(unittest.TestCase):
         buffer = []
         async def test3():
             nonlocal buffer
-            with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
+            with self.assertWarnsRegex(DeprecationWarning, "legacy"):
                 async for i in AsyncIter():
                     if i[0] > 20:
                         continue
@@ -1514,7 +1514,7 @@ class CoroutineTest(unittest.TestCase):
                 return 123
 
         async def foo():
-            with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
+            with self.assertWarnsRegex(DeprecationWarning, "legacy"):
                 async for i in I():
                     print('never going to happen')
 
@@ -1623,7 +1623,7 @@ class CoroutineTest(unittest.TestCase):
                 1/0
         async def foo():
             nonlocal CNT
-            with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
+            with self.assertWarnsRegex(DeprecationWarning, "legacy"):
                 async for i in AI():
                     CNT += 1
             CNT += 10
@@ -1650,7 +1650,7 @@ class CoroutineTest(unittest.TestCase):
         self.assertEqual(CNT, 0)
 
     def test_for_9(self):
-        # Test that PendingDeprecationWarning can safely be converted into
+        # Test that DeprecationWarning can safely be converted into
         # an exception (__aiter__ should not have a chance to raise
         # a ZeroDivisionError.)
         class AI:
@@ -1660,13 +1660,13 @@ class CoroutineTest(unittest.TestCase):
             async for i in AI():
                 pass
 
-        with self.assertRaises(PendingDeprecationWarning):
+        with self.assertRaises(DeprecationWarning):
             with warnings.catch_warnings():
                 warnings.simplefilter("error")
                 run_async(foo())
 
     def test_for_10(self):
-        # Test that PendingDeprecationWarning can safely be converted into
+        # Test that DeprecationWarning can safely be converted into
         # an exception.
         class AI:
             async def __aiter__(self):
@@ -1675,7 +1675,7 @@ class CoroutineTest(unittest.TestCase):
             async for i in AI():
                 pass
 
-        with self.assertRaises(PendingDeprecationWarning):
+        with self.assertRaises(DeprecationWarning):
             with warnings.catch_warnings():
                 warnings.simplefilter("error")
                 run_async(foo())
index b4a02431a796d812bd1b586b1ce22ca4a09138bf..7a4fa3a35ab72aae7ba7771809dbcfd032e2769a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,11 @@ Core and Builtins
 - Issue #28583: PyDict_SetDefault didn't combine split table when needed.
   Patch by Xiang Zhang.
 
+- Issue #27243: Change PendingDeprecationWarning -> DeprecationWarning.
+  As it was agreed in the issue, __aiter__ returning an awaitable
+  should result in PendingDeprecationWarning in 3.5 and in
+  DeprecationWarning in 3.6.
+
 Library
 -------
 
index 82cc9a283578f5dea2fb8c4fb7d08dde872a6218..0add7ecc09383506359c0b3d72836b405a1f6155 100644 (file)
@@ -1911,7 +1911,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
                 Py_DECREF(iter);
 
                 if (PyErr_WarnFormat(
-                        PyExc_PendingDeprecationWarning, 1,
+                        PyExc_DeprecationWarning, 1,
                         "'%.100s' implements legacy __aiter__ protocol; "
                         "__aiter__ should return an asynchronous "
                         "iterator, not awaitable",