summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-01-09 20:38:15 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-01-09 20:38:15 (GMT)
commita4815caa7ccf21aa994d0e0eec66873072f0e352 (patch)
tree5ccb44937ddfdd59ebae4590d2f4cfc05dcced3d /Lib/_pyio.py
parenta6c91f5e3b013be1447454b3a479d6fabbf16806 (diff)
downloadcpython-a4815caa7ccf21aa994d0e0eec66873072f0e352.zip
cpython-a4815caa7ccf21aa994d0e0eec66873072f0e352.tar.gz
cpython-a4815caa7ccf21aa994d0e0eec66873072f0e352.tar.bz2
Issue #10872: The repr() of TextIOWrapper objects now includes the mode
if available. (at Georg's request)
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 2a6e7a8..3c1e805 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1504,13 +1504,20 @@ class TextIOWrapper(TextIOBase):
# - "chars_..." for integer variables that count decoded characters
def __repr__(self):
+ result = "<_pyio.TextIOWrapper"
try:
name = self.name
except AttributeError:
- return "<_pyio.TextIOWrapper encoding={0!r}>".format(self.encoding)
+ pass
+ else:
+ result += " name={0!r}".format(name)
+ try:
+ mode = self.mode
+ except AttributeError:
+ pass
else:
- return "<_pyio.TextIOWrapper name={0!r} encoding={1!r}>".format(
- name, self.encoding)
+ result += " mode={0!r}".format(mode)
+ return result + " encoding={0!r}>".format(self.encoding)
@property
def encoding(self):