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 luizeldorado
Recipients luizeldorado
Date 2020-08-14.00:10:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If you use the pprint function when running on windowed mode (either by using the .pyw extension or running the file with pythonw) a "AttributeError" exception occurs, saying that "'NoneType' object has no attribute 'write'".

Looking at the source code (Lib/, it happens because in this mode sys.stdout is set to None, therefore it has no write attribute.

I think intended behavior is to simply ignore any console output when in this mode, since many programs have loads of print statements for debugging with a console window; it shouldn't crash because of a extension change.

There's two solutions I can think of. One is to check if sys.stdout is None, not printing anything in case it is. Another is, when in windowed mode, setting sys.stdout to some dummy null file. This has the advantage of automatically fixing this in other parts of Python where this error might also occur.

This error is particularly hard to find, since in windowed mode there's no console to show the exception - it simply closes. In the attached file, where I showcase the error, I have to log to a file to see the problem.

I'm not sure how can this be unnoticed for so much time, it can't possibly be intended, or maybe it is and it's print() that actually has a problem, lol.
Date User Action Args
2020-08-14 00:10:04luizeldoradosetrecipients: + luizeldorado
2020-08-14 00:10:04luizeldoradosetmessageid: <>
2020-08-14 00:10:04luizeldoradolinkissue41546 messages
2020-08-14 00:10:03luizeldoradocreate