pixelb / crudini

A utility for manipulating ini files
GNU General Public License v2.0
443 stars 63 forks source link

handle closed stdout gracefully #84

Closed pixelb closed 3 years ago

pixelb commented 3 years ago

Don't error when stdout is closed, but don't actually need it. Also give a clear message when stdout is closed but we need it.

Fixes issue #82

pixelb commented 3 years ago

For my reference, I notice that print() is a noop when sys.stdout is None. Also we don't protect all sys.stdout.write() calls as we handle it at a higher level before these are reached

pixelb commented 3 years ago

For my reference I see that sys.stdout etc. is only set to None with python3. It's a bit strange TBH that python3 will now just ignore print() statements when stdout is closed, rather than generating an error. Anyway I'll adjust so that we detect closed stdin and stdout on python2 also