Issue #18919: If the close() method of a writer in the sunau or wave module
failed, second invocation of close() and destructor no more raise an
exception.  Second invocation of close() on sunau writer now has no effects.
The aifc module now accepts lower case of names of the 'ulaw' and 'alaw'
codecs.
diff --git a/Lib/sunau.py b/Lib/sunau.py
index 4f0885a..31b280d 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -406,12 +406,15 @@
             self._patchheader()
 
     def close(self):
-        self._ensure_header_written()
-        if self._nframeswritten != self._nframes or \
-                  self._datalength != self._datawritten:
-            self._patchheader()
-        self._file.flush()
-        self._file = None
+        if self._file:
+            try:
+                self._ensure_header_written()
+                if self._nframeswritten != self._nframes or \
+                        self._datalength != self._datawritten:
+                    self._patchheader()
+                self._file.flush()
+            finally:
+                self._file = None
 
     #
     # private methods