bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)

This commit is contained in:
Serhiy Storchaka 2019-08-29 09:25:22 +03:00 committed by GitHub
parent f5896a05ed
commit b235a1b473
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 22 deletions

View file

@ -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)