minrk/wurlitzer

sys.__stdout__ can be None

Closed this issue · 1 comments

See spyder-ide/spyder-kernels#191

According to https://docs.python.org/3.8/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.

This line:

real_fd = getattr(sys, '__%s__' % name).fileno()

Assumes they are not. Should there be an extra test? I am not sure how to handle this error.

minrk commented

Good question! Wurlitzer won't be able to capture output if this happens, I think, so it's a bit unclear if it should warn or raise, but it should probably be one or the other. My guess is, given the context, that Wurlitzer itself should raise (since it's failing to do what you are asking it to), but the IPython extension should demote that to a warning.