summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index a819d26..68089a5 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -2605,9 +2605,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def _print_message(self, message, file=None):
if message:
- if file is None:
- file = _sys.stderr
- file.write(message)
+ file = file or _sys.stderr
+ try:
+ file.write(message)
+ except (AttributeError, OSError):
+ pass
# ===============
# Exiting methods