[Python-checkins] cpython (merge 3.4 -> default): Issue #22613: Fix reprlib.Repr subclass example on Python 3.

berker.peksag python-checkins at python.org
Sun Oct 12 04:11:06 CEST 2014


https://hg.python.org/cpython/rev/7394e5f85284
changeset:   92966:7394e5f85284
parent:      92964:83540d7b7366
parent:      92965:7659f06a3648
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Sun Oct 12 05:11:40 2014 +0300
summary:
  Issue #22613: Fix reprlib.Repr subclass example on Python 3.

Reported by Jacques Ducasse.

files:
  Doc/library/reprlib.rst |  8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/Doc/library/reprlib.rst b/Doc/library/reprlib.rst
--- a/Doc/library/reprlib.rst
+++ b/Doc/library/reprlib.rst
@@ -148,11 +148,11 @@
    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>'

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list