]> granicus.if.org Git - python/commitdiff
Ignore IOError exceptions when writing the message.
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 11 Sep 2002 13:22:35 +0000 (13:22 +0000)
committerMark Hammond <mhammond@skippinet.com.au>
Wed, 11 Sep 2002 13:22:35 +0000 (13:22 +0000)
Lib/warnings.py

index 383e62383aa629ac0da92517675482bc328c927e..a74e1bab8006bcb2b8322db15d3ac06caa687e4f 100644 (file)
@@ -107,7 +107,10 @@ def showwarning(message, category, filename, lineno, file=None):
     """Hook to write a warning to a file; replace if you like."""
     if file is None:
         file = sys.stderr
-    file.write(formatwarning(message, category, filename, lineno))
+    try:
+        file.write(formatwarning(message, category, filename, lineno))
+    except IOError:
+        pass # the file (probably stderr) is invalid - this warning gets lost.
 
 def formatwarning(message, category, filename, lineno):
     """Function to format a warning the standard way."""