ui: look before you leap on sys.stderr.closed (and look nicer)
f83291e5643e introduced a fix if sys.stdout.closed does not exist.
This change uses a getattr with default instead of hasattr (which just calls
getattr) and accessing the attribute.
Additionally it applies the same fix for sys.stderr.closed as this is not
available in the bpython shell (reported by Roger Gammans).