From: Mark Hammond Date: Wed, 11 Sep 2002 13:22:35 +0000 (+0000) Subject: Ignore IOError exceptions when writing the message. X-Git-Tag: v2.3c1~4138 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51a0ae3f97cdeccd57f733fd62417b59619e3bf7;p=python Ignore IOError exceptions when writing the message. --- diff --git a/Lib/warnings.py b/Lib/warnings.py index 383e62383a..a74e1bab80 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -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."""