Skip to content

Conversation

cmaloney
Copy link
Contributor

@cmaloney cmaloney commented Oct 2, 2025

These don't "redirect" like a terminal where typically the file pointed to by fd 1 and 2 are made the "same" (ex. by dup2 the given fd into that specific fd number). Rather, these context managers set the respective globals to the provided value. In most cases that should be a "file object".


📚 Documentation preview 📚: https://cpython-previews--139490.org.readthedocs.build/

These don't "redirect" like a terminal where typically the file pointed
to by fd 1 and 2 are made the "same" by the preparing process (ex. by
`dup2` the given fd into that specific fd number). Rather, these context
managers set the respective globals to the provided value. In most cases
that should be a "file object".
@cmaloney
Copy link
Contributor Author

cmaloney commented Oct 3, 2025

@wolfgang-eder how does this look to you?

@rhettinger rhettinger self-assigned this Oct 6, 2025
@rhettinger
Copy link
Contributor

Please limit the edit to just :term:file object.

@wolfgang-eder
Copy link

Thank you for improving the documentation. I am happy with the changes

Similar to :func:`~contextlib.redirect_stdout` but redirecting
:data:`sys.stderr` to another file or file-like object.
Similar to :func:`~contextlib.redirect_stdout` but redirecting the global
:data:`sys.stderr` to another value, typically a :term:`file object`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "another target" would be better here than "another value"?

@cmaloney
Copy link
Contributor Author

cmaloney commented Oct 6, 2025

@rhettinger to check my understanding: reduce to just the "file or file-like object." -> :term:file object; don't add new example or expand on behavior description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants