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).
adding a
popping c.patch
popping b.patch
now at: a.patch
applying b.patch
applying c.patch
now at: c.patch
popping c.patch
now at: b.patch
% Using index
popping b.patch
now at: a.patch
applying b.patch
applying c.patch
now at: c.patch
% No warnings when using index
popping bug141421
popping bug314159
popping c.patch
now at: b.patch
applying c.patch
applying bug314159
now at: bug314159
% Detect ambiguous non-index
patch name "14" is ambiguous:
bug314159
bug141421
abort: patch 14 not in series