This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients luizeldorado, ned.deily, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
Date 2020-08-14.22:15:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If you run in windowed mode, you are expected to either not use sys.stdout or to provide a working sys.stdout object.  I am not sure if that is explicitly documented as I cannot find python.exe and pythonw.exe or .py or .pyw in the index and
does not mention the pyw version.

But this is not really a windowed mode issue.  In a Windows console:
>>> print('hello')
>>> import sys; sys.stdout = None
>>> print('hello')
>>> sys.stdout = sys.__stdout__
>>> print('hello')

print and pprint act differently because pprint uses stream.write without try/except.  Check the doc or code.  So pprint users must run it with a stream with that method.  Otherwise, failure is to be expected.

If you try to print to None, print defaults to sys.stdout.  The doc does not define what happens when the latter is None.  On CPython, print passes.  But maybe this is left undefined intentionally.  It must either check that file is not None or catch the AttributeError.

>Shouldn't it say that it can't print because there's no stdout? 
How could it if there is no channel to speak?  I guess Guido decided to silently pass rather than silently exit.  Debug prints should not crash a program.

So closing as 'Not a bug' would be one appropriate resolution for this issue.
Date User Action Args
2020-08-14 22:15:33terry.reedysetrecipients: + terry.reedy, paul.moore, tim.golden, ned.deily, zach.ware, steve.dower, luizeldorado
2020-08-14 22:15:33terry.reedysetmessageid: <>
2020-08-14 22:15:33terry.reedylinkissue41546 messages
2020-08-14 22:15:33terry.reedycreate