Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2edd8a1

Browse files
committed
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.
1 parent 1c9bd1d commit 2edd8a1

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

Lib/test/test_coroutines.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ async def __anext__(self):
13981398

13991399
buffer = []
14001400
async def test1():
1401-
with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
1401+
with self.assertWarnsRegex(DeprecationWarning, "legacy"):
14021402
async for i1, i2 in AsyncIter():
14031403
buffer.append(i1 + i2)
14041404

@@ -1412,7 +1412,7 @@ async def test1():
14121412
buffer = []
14131413
async def test2():
14141414
nonlocal buffer
1415-
with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
1415+
with self.assertWarnsRegex(DeprecationWarning, "legacy"):
14161416
async for i in AsyncIter():
14171417
buffer.append(i[0])
14181418
if i[0] == 20:
@@ -1431,7 +1431,7 @@ async def test2():
14311431
buffer = []
14321432
async def test3():
14331433
nonlocal buffer
1434-
with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
1434+
with self.assertWarnsRegex(DeprecationWarning, "legacy"):
14351435
async for i in AsyncIter():
14361436
if i[0] > 20:
14371437
continue
@@ -1514,7 +1514,7 @@ def __anext__(self):
15141514
return 123
15151515

15161516
async def foo():
1517-
with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
1517+
with self.assertWarnsRegex(DeprecationWarning, "legacy"):
15181518
async for i in I():
15191519
print('never going to happen')
15201520

@@ -1623,7 +1623,7 @@ async def __aiter__(self):
16231623
1/0
16241624
async def foo():
16251625
nonlocal CNT
1626-
with self.assertWarnsRegex(PendingDeprecationWarning, "legacy"):
1626+
with self.assertWarnsRegex(DeprecationWarning, "legacy"):
16271627
async for i in AI():
16281628
CNT += 1
16291629
CNT += 10
@@ -1650,7 +1650,7 @@ async def foo():
16501650
self.assertEqual(CNT, 0)
16511651

16521652
def test_for_9(self):
1653-
# Test that PendingDeprecationWarning can safely be converted into
1653+
# Test that DeprecationWarning can safely be converted into
16541654
# an exception (__aiter__ should not have a chance to raise
16551655
# a ZeroDivisionError.)
16561656
class AI:
@@ -1660,13 +1660,13 @@ async def foo():
16601660
async for i in AI():
16611661
pass
16621662

1663-
with self.assertRaises(PendingDeprecationWarning):
1663+
with self.assertRaises(DeprecationWarning):
16641664
with warnings.catch_warnings():
16651665
warnings.simplefilter("error")
16661666
run_async(foo())
16671667

16681668
def test_for_10(self):
1669-
# Test that PendingDeprecationWarning can safely be converted into
1669+
# Test that DeprecationWarning can safely be converted into
16701670
# an exception.
16711671
class AI:
16721672
async def __aiter__(self):
@@ -1675,7 +1675,7 @@ async def foo():
16751675
async for i in AI():
16761676
pass
16771677

1678-
with self.assertRaises(PendingDeprecationWarning):
1678+
with self.assertRaises(DeprecationWarning):
16791679
with warnings.catch_warnings():
16801680
warnings.simplefilter("error")
16811681
run_async(foo())

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ Core and Builtins
1313
- Issue #28583: PyDict_SetDefault didn't combine split table when needed.
1414
Patch by Xiang Zhang.
1515

16+
- Issue #27243: Change PendingDeprecationWarning -> DeprecationWarning.
17+
As it was agreed in the issue, __aiter__ returning an awaitable
18+
should result in PendingDeprecationWarning in 3.5 and in
19+
DeprecationWarning in 3.6.
20+
1621
Library
1722
-------
1823

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
19111911
Py_DECREF(iter);
19121912

19131913
if (PyErr_WarnFormat(
1914-
PyExc_PendingDeprecationWarning, 1,
1914+
PyExc_DeprecationWarning, 1,
19151915
"'%.100s' implements legacy __aiter__ protocol; "
19161916
"__aiter__ should return an asynchronous "
19171917
"iterator, not awaitable",

0 commit comments

Comments
 (0)