diff options
author | Mark Hammond <mhammond@skippinet.com.au> | 2002-09-11 13:22:35 (GMT) |
---|---|---|
committer | Mark Hammond <mhammond@skippinet.com.au> | 2002-09-11 13:22:35 (GMT) |
commit | 51a0ae3f97cdeccd57f733fd62417b59619e3bf7 (patch) | |
tree | 1b2a90ed26f60a6050840001e83ff48706ac308a /Lib/warnings.py | |
parent | ccd9e75b189c8084b08af797c5711938685b8b5b (diff) | |
download | cpython-51a0ae3f97cdeccd57f733fd62417b59619e3bf7.zip cpython-51a0ae3f97cdeccd57f733fd62417b59619e3bf7.tar.gz cpython-51a0ae3f97cdeccd57f733fd62417b59619e3bf7.tar.bz2 |
Ignore IOError exceptions when writing the message.
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r-- | Lib/warnings.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py index 383e623..a74e1ba 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.""" |