mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)
This commit is contained in:
parent
f5896a05ed
commit
b235a1b473
4 changed files with 22 additions and 22 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue