From 342247363ce41129802ff6a915c3081849c46f66 Mon Sep 17 00:00:00 2001 From: Matty Patatty Date: Sun, 2 Oct 2022 19:06:14 +1300 Subject: [PATCH 1/2] Fix default file in `Task.print_stack` `Task.print_stack` is described by documentation as having a default output file of `sys.stderr`. However, instead the default `None` is passed all the way to `print` statements, leading to an actual default of `sys.stdout`. Fix by setting the file to `sys.stderr` when the default is used. --- Lib/asyncio/tasks.py | 3 +++ 1 file changed, 3 insertions(+) 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): From 4deb2a1ffb068e347a20cd1122e5bebd94058b5a Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 2 Oct 2022 06:26:26 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2022-10-02-06-26-25.gh-issue-97725.icupGE.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2022-10-02-06-26-25.gh-issue-97725.icupGE.rst 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.