Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

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:

Suggested change
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)

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.

matplotlib.interactive(True)
else:
if matplotlib.is_interactive():
sys.stdout.write("Backend %s is non-interactive backend. Turning interactive mode off.\n" % backend)
sys.stderr.write("Backend %s is non-interactive backend. Turning interactive mode off.\n" % backend)
matplotlib.interactive(False)
patch_use(enable_gui_function)
patch_is_interactive()
Expand Down
Loading