-
Notifications
You must be signed in to change notification settings - Fork 165
Do not write to stdout on debugging #1892
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
base: main
Are you sure you want to change the base?
Conversation
Write to stderr instead of stdout when changing Matplotlib interactivity. Otherwise the doctests will fail when debugging them. I tested this by changing it manually on my VSCode instance 😁.
I think this is okay, but what is failing with writing to stdout? |
Whatever you write to stdout appears in the doctest output, and thus it does not match the expected output anymore, failing the test. |
@@ -140,11 +140,11 @@ def activate_matplotlib(enable_gui_function): | |||
if is_interactive: | |||
enable_gui_function(gui) | |||
if not matplotlib.is_interactive(): | |||
sys.stdout.write("Backend %s is interactive backend. Turning interactive mode on.\n" % backend) | |||
sys.stderr.write("Backend %s is interactive backend. Turning interactive mode on.\n" % backend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking this shouldn't write to either. It should probably write to the log instead.
That would be something like this instead:
sys.stderr.write("Backend %s is interactive backend. Turning interactive mode on.\n" % backend) | |
pydev_log.debug("Backend %s is interactive backend. Turning interactive mode on.\n" % backend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course after importing pdev_log. Maybe that causes some import problems though and it's why this code was writing to stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to stderr
because I saw it writing to stderr
in other places in the same file, but logging is fine to me, as long as it does not end in stdout
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah not sure why it's writing to stderr instead of log elsewhere. I believe this code was originally a port from somewhere else and maybe whomever ported it didn't bother to make it write to the log instead.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Write to stderr instead of stdout when changing Matplotlib interactivity. Otherwise the doctests will fail when debugging them.
I tested this by changing it manually on my VSCode instance 😁.