mirror of https://github.com/python/cpython.git
Ignore IOError exceptions when writing the message.
This commit is contained in:
parent
ccd9e75b18
commit
51a0ae3f97
|
@ -107,7 +107,10 @@ def showwarning(message, category, filename, lineno, file=None):
|
||||||
"""Hook to write a warning to a file; replace if you like."""
|
"""Hook to write a warning to a file; replace if you like."""
|
||||||
if file is None:
|
if file is None:
|
||||||
file = sys.stderr
|
file = sys.stderr
|
||||||
|
try:
|
||||||
file.write(formatwarning(message, category, filename, lineno))
|
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):
|
def formatwarning(message, category, filename, lineno):
|
||||||
"""Function to format a warning the standard way."""
|
"""Function to format a warning the standard way."""
|
||||||
|
|
Loading…
Reference in New Issue