Ignore IOError exceptions when writing the message.

This commit is contained in:
Mark Hammond 2002-09-11 13:22:35 +00:00
parent ccd9e75b18
commit 51a0ae3f97
1 changed files with 4 additions and 1 deletions

View 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
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."""