From b7a7f0b08e64fcb2cf083c10773a652d724bc0ea 2017-01-09 13:14:28 From: Thomas Kluyver Date: 2017-01-09 13:14:28 Subject: [PATCH] Merge pull request #10142 from srinivasreddy/CUnicodeIO Replace CUnicodeIO references with StringIO from io package. --- diff --git a/IPython/core/formatters.py b/IPython/core/formatters.py index d441d68..9f5ded5 100644 --- a/IPython/core/formatters.py +++ b/IPython/core/formatters.py @@ -15,6 +15,7 @@ import json import sys import traceback import warnings +from io import StringIO from decorator import decorator @@ -655,11 +656,7 @@ class PlainTextFormatter(BaseFormatter): if not self.pprint: return repr(obj) else: - # handle str and unicode on Python 2 - # io.StringIO only accepts unicode, - # cStringIO doesn't handle unicode on py2, - # StringIO allows str, unicode but only ascii str - stream = pretty.CUnicodeIO() + stream = StringIO() printer = pretty.RepresentationPrinter(stream, self.verbose, self.max_width, self.newline, max_seq_length=self.max_seq_length, diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py index 4c18089..155dfee 100644 --- a/IPython/lib/pretty.py +++ b/IPython/lib/pretty.py @@ -83,12 +83,11 @@ import types import re import datetime from collections import deque +from io import StringIO from IPython.utils.py3compat import PYPY, cast_unicode from IPython.utils.encoding import get_stream_enc -from io import StringIO - __all__ = ['pretty', 'pprint', 'PrettyPrinter', 'RepresentationPrinter', 'for_type', 'for_type_by_name'] @@ -114,7 +113,7 @@ def pretty(obj, verbose=False, max_width=79, newline='\n', max_seq_length=MAX_SE """ Pretty print the object's representation. """ - stream = CUnicodeIO() + stream = StringIO() printer = RepresentationPrinter(stream, verbose, max_width, newline, max_seq_length=max_seq_length) printer.pretty(obj) printer.flush()