[issue1415] py3k: pythonw.exe fails because std streams a missing

Christian Heimes report at bugs.python.org
Tue Nov 13 17:35:23 CET 2007


Christian Heimes added the comment:

As far as I can see print() works if sys.stdout is either None (discard
output ASAP) or a file like object. Even print(file=syst.stderr) works.

sys.stdout.write() is going to fail when sys.stdout is None but that's
not my concern. It's another well documented difference between Python
2.x and 3.x. If people still need a valid but no op stdout they can set
up their own:

class NullWriter:
    def write(self, data):
        pass

if sys.stdout is None:
    sys.stdout = NullWriter()

Done ;)

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1415>
__________________________________


More information about the Python-bugs-list mailing list