aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/warnings.py
diff options
context:
space:
mode:
authorSebastian Rittau <srittau@rittau.biz>2024-07-23 11:59:28 +0200
committerGitHub <noreply@github.com>2024-07-23 10:59:28 +0100
commit375c9f6dfb78345dd0966d6f3b281f15107b0561 (patch)
tree57c42dcd869a38d15d775e17b2f1ad104db46e49 /Lib/warnings.py
parent2a5d1eb7073179a13159bce937afdbe240432e7d (diff)
downloadcpython-375c9f6dfb78345dd0966d6f3b281f15107b0561.tar.gz
cpython-375c9f6dfb78345dd0966d6f3b281f15107b0561.zip
gh-122088: Copy the coroutine status of the underlying callable in `@warnings.deprecated` (#122086)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r--Lib/warnings.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py
index d344ceaebb0..e83cde37ab2 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -628,12 +628,16 @@ class deprecated:
return arg
elif callable(arg):
import functools
+ import inspect
@functools.wraps(arg)
def wrapper(*args, **kwargs):
warn(msg, category=category, stacklevel=stacklevel + 1)
return arg(*args, **kwargs)
+ if inspect.iscoroutinefunction(arg):
+ wrapper = inspect.markcoroutinefunction(wrapper)
+
arg.__deprecated__ = wrapper.__deprecated__ = msg
return wrapper
else: