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

if redirect=False, wx.App should set stdout and stderr to os.devnull #2585

Open
ChrisBarker-NOAA opened this issue Aug 5, 2024 · 0 comments

Comments

@ChrisBarker-NOAA
Copy link

On Windows, the pythonw interpreter sets sys.stdout and sys.stderr to None.

This is because Windows itself does not set up a default stdio streams when starting an app from the GUI.

Which, of course, is why the redirect flag exists.

But if you don't redirect, then you get broken stdio streams.

This is a problem, because third party libraries may well write to the standard streams -- as it's a reasonable assumption that they be there and be valid, and then you get a crash.

There's discussion about whether pythonw should set them to None:

python/cpython#122633

But for now, and for the foreseeable future, it will be that way, so it would be great if wxPython had something like:

if sys.stdout is None:
    sys.stdout = open(os.devnull, "w")
if sys.stderr is None:
    sys.stderr = open(os.devnull, "w")

in the App startup code.

Users, could, of course, redirect them any other way that want.

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

No branches or pull requests

1 participant