From: Raymond Hettinger Date: Sun, 6 Oct 2002 03:18:34 +0000 (+0000) Subject: Backport 1.17: X-Git-Tag: v2.2.2b1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65e03cd7b86387fc92f5c8375e3f169b27364109;p=thirdparty%2FPython%2Fcpython.git Backport 1.17: Ignore IOError exceptions when writing the message. --- diff --git a/Lib/warnings.py b/Lib/warnings.py index 1e94f59da31e..cdc290e52661 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -98,7 +98,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."""