mirror of https://github.com/python/cpython
Issue #22613: Fix reprlib.Repr subclass example on Python 3.
Reported by Jacques Ducasse.
This commit is contained in:
commit
8a01b71f35
|
@ -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>'
|
||||||
|
|
Loading…
Reference in New Issue