8000 gh-97725: Fix default file in `Task.print_stack` by megabug · Pull Request #97726 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-97725: Fix default file in Task.p 8000 rint_stack #97726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
megabug authored Oct 2, 2022
commit 342247363ce41129802ff6a915c3081849c46f66
3 changes: 3 additions & 0 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import functools
import inspect
import itertools
import sys
import types
import warnings
import weakref
Expand Down Expand Up @@ -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):
Expand Down
0