mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #22613: Fix reprlib.Repr subclass example on Python 3.
Reported by Jacques Ducasse.
This commit is contained in:
parent
36d8ef9cc7
commit
edd6ec2dd3
1 changed files with 4 additions and 4 deletions
|
@ -148,11 +148,11 @@ for file objects could be added::
|
|||
import sys
|
||||
|
||||
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
|
||||
else:
|
||||
return repr(obj)
|
||||
return repr(obj)
|
||||
|
||||
aRepr = MyRepr()
|
||||
print(aRepr.repr(sys.stdin)) # prints '<stdin>'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue