summaryrefslogtreecommitdiff
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-08-29 09:25:22 +0300
committerGitHub <noreply@github.com>2019-08-29 09:25:22 +0300
commitb235a1b47394eedc5f8ea4cf214f56c4c6932e59 (patch)
tree462594be94793d0fa1b757c8352925286e54264b /Lib/_pyio.py
parentf5896a05edf5df91fb1b55bd481ba5b2a3682f4e (diff)
downloadcpython-git-b235a1b47394eedc5f8ea4cf214f56c4c6932e59.tar.gz
bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 40e0c9f9e2..1b24ef9f0e 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -409,7 +409,7 @@ class IOBase(metaclass=abc.ABCMeta):
"""Destructor. Calls close()."""
try:
closed = self.closed
- except Exception:
+ except AttributeError:
# If getting closed fails, then the object is probably
# in an unusable state, so ignore.
return
@@ -867,7 +867,7 @@ class _BufferedIOMixin(BufferedIOBase):
clsname = self.__class__.__qualname__
try:
name = self.name
- except Exception:
+ except AttributeError:
return "<{}.{}>".format(modname, clsname)
else:
return "<{}.{} name={!r}>".format(modname, clsname, name)
@@ -2083,13 +2083,13 @@ class TextIOWrapper(TextIOBase):
self.__class__.__qualname__)
try:
name = self.name
- except Exception:
+ except AttributeError:
pass
else:
result += " name={0!r}".format(name)
try:
mode = self.mode
- except Exception:
+ except AttributeError:
pass
else:
result += " mode={0!r}".format(mode)