Commit 8a01b71f authored by Berker Peksag's avatar Berker Peksag

Issue #22613: Fix reprlib.Repr subclass example on Python 3.

Reported by Jacques Ducasse.
parents 870903e9 edd6ec2d
...@@ -148,11 +148,11 @@ for file objects could be added:: ...@@ -148,11 +148,11 @@ for file objects could be added::
import sys import sys
class MyRepr(reprlib.Repr): class MyRepr(reprlib.Repr):
def repr_file(self, obj, level):
if obj.name in ['<stdin>', '<stdout>', '<stderr>']: def repr_TextIOWrapper(self, obj, level):
if obj.name in {'<stdin>', '<stdout>', '<stderr>'}:
return obj.name return obj.name
else: return repr(obj)
return repr(obj)
aRepr = MyRepr() aRepr = MyRepr()
print(aRepr.repr(sys.stdin)) # prints '<stdin>' print(aRepr.repr(sys.stdin)) # prints '<stdin>'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment