diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-08-29 06:25:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-29 06:25:22 (GMT) |
commit | b235a1b47394eedc5f8ea4cf214f56c4c6932e59 (patch) | |
tree | 462594be94793d0fa1b757c8352925286e54264b /Lib | |
parent | f5896a05edf5df91fb1b55bd481ba5b2a3682f4e (diff) | |
download | cpython-b235a1b47394eedc5f8ea4cf214f56c4c6932e59.zip cpython-b235a1b47394eedc5f8ea4cf214f56c4c6932e59.tar.gz cpython-b235a1b47394eedc5f8ea4cf214f56c4c6932e59.tar.bz2 |
bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/_pyio.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 40e0c9f..1b24ef9 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) |