]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46995: Deprecate missing asyncio.Task.set_name() for third-party task implementat...
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Sun, 13 Mar 2022 16:34:46 +0000 (18:34 +0200)
committerGitHub <noreply@github.com>
Sun, 13 Mar 2022 16:34:46 +0000 (18:34 +0200)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Lib/asyncio/tasks.py
Lib/test/test_asyncio/test_tasks.py
Misc/NEWS.d/next/Library/2022-03-12-13-50-42.bpo-46995.2kdNDg.rst [new file with mode: 0644]

index 059143fb9086fb087089844e8fcd579d76199ed5..e604298e5efc01d3750817f36702737ecf37fe89 100644 (file)
@@ -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 in Python 3.8, "
+                      "the method support will be mandatory for third-party "
+                      "task implementations since 3.13.",
+                      DeprecationWarning, stacklevel=3)
         else:
             set_name(name)
 
index 950879204e703b758920c78f195fd8f2eb8e0610..95fabf728818bb62bbeb4874c45c9c5076a049c3 100644 (file)
@@ -12,7 +12,6 @@ import sys
 import textwrap
 import traceback
 import unittest
-import weakref
 from unittest import mock
 from types import GenericAlias
 
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 (file)
index 0000000..021923f
--- /dev/null
@@ -0,0 +1,2 @@
+Deprecate missing :meth:`asyncio.Task.set_name` for third-party task
+implementations, schedule making it mandatory in Python 3.13.