From 0032450f787b70138444efdd88adfa2bb9b6222c Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 12 Mar 2022 13:51:27 +0200 Subject: [PATCH 1/5] bpo-46995: Deprecate missing asyncio.Task.set_name() for third-party task implementations --- Lib/asyncio/tasks.py | 5 ++++- .../next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index 059143fb9086fb..0687e9e0bd2ce6 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -67,7 +67,10 @@ def _set_task_name(task, name): try: set_name = task.set_name except AttributeError: - pass + warnings.warn("Task.set_name() was added by Python 3.8, " + "the method support will be mandatory for third-party " + "task implementations since 3.13.", + DeprecationWarning, stacklevel=2) else: set_name(name) diff --git a/Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst b/Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst new file mode 100644 index 00000000000000..8c52cefafc439d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst @@ -0,0 +1,2 @@ +Deprecate missing :meth:`asyncio.Task.set_name` for third-party task +implementations, schedule the making it mandatory in Python 3.13. From 6494e19e6c9dce1666c02e2526523c4ad6237bbe Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 12 Mar 2022 15:21:09 +0200 Subject: [PATCH 2/5] Update Lib/asyncio/tasks.py Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- Lib/asyncio/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index 0687e9e0bd2ce6..cedeba3bde2a0c 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -67,7 +67,7 @@ def _set_task_name(task, name): try: set_name = task.set_name except AttributeError: - warnings.warn("Task.set_name() was added by Python 3.8, " + warnings.warn("Task.set_name() was added in Python 3.8, " "the method support will be mandatory for third-party " "task implementations since 3.13.", DeprecationWarning, stacklevel=2) From 92dc770f4e53356548750675f65424a7ab19d3b3 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 12 Mar 2022 15:21:18 +0200 Subject: [PATCH 3/5] Update Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- .../next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst b/Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst index 8c52cefafc439d..021923f5889a7f 100644 --- a/Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst +++ b/Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst @@ -1,2 +1,2 @@ Deprecate missing :meth:`asyncio.Task.set_name` for third-party task -implementations, schedule the making it mandatory in Python 3.13. +implementations, schedule making it mandatory in Python 3.13. From 067c8e53b674ed905d9796d2eaa260bf18937b01 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 12 Mar 2022 19:41:02 +0200 Subject: [PATCH 4/5] Update Lib/asyncio/tasks.py --- Lib/asyncio/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index cedeba3bde2a0c..e604298e5efc01 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -70,7 +70,7 @@ def _set_task_name(task, name): warnings.warn("Task.set_name() was added in Python 3.8, " "the method support will be mandatory for third-party " "task implementations since 3.13.", - DeprecationWarning, stacklevel=2) + DeprecationWarning, stacklevel=3) else: set_name(name) From 8e667ea2b64bdcde2d5eab81d743da0eb94a1448 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sun, 13 Mar 2022 16:08:03 +0200 Subject: [PATCH 5/5] Drop unused import --- Lib/test/test_asyncio/test_tasks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 950879204e703b..95fabf728818bb 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -12,7 +12,6 @@ import textwrap import traceback import unittest -import weakref from unittest import mock from types import GenericAlias