Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a01b71

Browse files
committed
Issue #22613: Fix reprlib.Repr subclass example on Python 3.
Reported by Jacques Ducasse.
2 parents 870903e + edd6ec2 commit 8a01b71

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Doc/library/reprlib.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ for file objects could be added::
148148
import sys
149149

150150
class MyRepr(reprlib.Repr):
151-
def repr_file(self, obj, level):
152-
if obj.name in ['<stdin>', '<stdout>', '<stderr>']:
151+
152+
def repr_TextIOWrapper(self, obj, level):
153+
if obj.name in {'<stdin>', '<stdout>', '<stderr>'}:
153154
return obj.name
154-
else:
155-
return repr(obj)
155+
return repr(obj)
156156

157157
aRepr = MyRepr()
158158
print(aRepr.repr(sys.stdin)) # prints '<stdin>'

0 commit comments

Comments
 (0)