allow more operations to work on detached streams (closes #23093)

Patch by Martin Panter.
This commit is contained in:
Benjamin Peterson 2014-12-21 20:51:50 -06:00
parent fe3dc376fa
commit 10e76b67c9
5 changed files with 61 additions and 42 deletions

View file

@ -793,7 +793,7 @@ class _BufferedIOMixin(BufferedIOBase):
clsname = self.__class__.__name__
try:
name = self.name
except AttributeError:
except Exception:
return "<_pyio.{0}>".format(clsname)
else:
return "<_pyio.{0} name={1!r}>".format(clsname, name)
@ -1561,13 +1561,13 @@ class TextIOWrapper(TextIOBase):
result = "<_pyio.TextIOWrapper"
try:
name = self.name
except AttributeError:
except Exception:
pass
else:
result += " name={0!r}".format(name)
try:
mode = self.mode
except AttributeError:
except Exception:
pass
else:
result += " mode={0!r}".format(mode)