Skip to content
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

Replace sys.stderr.write() with print(file=sys.stderr) #1131

Merged
merged 2 commits into from
Feb 15, 2024
Merged

Conversation

wch
Copy link
Collaborator

@wch wch commented Feb 15, 2024

This addresses #1054.

In some cases, sys.stdout and sys.stderr can be None, which would cause sys.stderr.write() to throw an error. This changes it to use print(file=sys.stderr), which will not throw an error when sys.stderr is None.

From https://docs.python.org/3/library/sys.html#sys.__stderr__:

Under some conditions stdin, stdout and stderr as well as the original values __stdin__, __stdout__ and __stderr__ can be None. It is usually the case for Windows GUI apps that aren’t connected to a console and Python apps started with pythonw.

@wch wch merged commit 8450dd1 into main Feb 15, 2024
26 checks passed
@wch wch deleted the print-sys-stderr branch February 15, 2024 20:46
schloerke added a commit that referenced this pull request Feb 16, 2024
* main:
  bug(module): Do not use the module prefix in the `Renderer.output_id` (#1130)
  Replace `sys.stderr.write()` with `print(file=sys.stderr)` (#1131)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant