diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index e48da0f2008829..3ab58899a96102 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -14,6 +14,7 @@ import functools import inspect import itertools +import sys import types import warnings import weakref @@ -183,6 +184,8 @@ def print_stack(self, *, limit=None, file=None): to which the output is written; by default output is written to sys.stderr. """ + if file is None: + file = sys.stderr return base_tasks._task_print_stack(self, limit, file) def cancel(self, msg=None): diff --git a/Misc/NEWS.d/next/Library/2022-10-02-06-26-25.gh-issue-97725.icupGE.rst b/Misc/NEWS.d/next/Library/2022-10-02-06-26-25.gh-issue-97725.icupGE.rst new file mode 100644 index 00000000000000..8c19643a65e854 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-10-02-06-26-25.gh-issue-97725.icupGE.rst @@ -0,0 +1 @@ +Make :meth:`asyncio.Task.print_task` use ``sys.stderr`` by default, as documented.